mirror of
https://github.com/pnpm/action-setup.git
synced 2025-02-23 14:22:26 +08:00
feat: support package.yaml
(#156)
This commit is contained in:
parent
e303250a24
commit
0cb0538c33
|
@ -6,6 +6,7 @@ import path from 'path'
|
||||||
import { execPath } from 'process'
|
import { execPath } from 'process'
|
||||||
import util from 'util'
|
import util from 'util'
|
||||||
import { Inputs } from '../inputs'
|
import { Inputs } from '../inputs'
|
||||||
|
import YAML from 'yaml'
|
||||||
|
|
||||||
export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
||||||
const { version, dest, packageJsonFile, standalone } = inputs
|
const { version, dest, packageJsonFile, standalone } = inputs
|
||||||
|
@ -49,7 +50,11 @@ async function readTarget(opts: {
|
||||||
|
|
||||||
if (GITHUB_WORKSPACE) {
|
if (GITHUB_WORKSPACE) {
|
||||||
try {
|
try {
|
||||||
({ packageManager } = JSON.parse(readFileSync(path.join(GITHUB_WORKSPACE, packageJsonFile), 'utf8')))
|
const content = readFileSync(path.join(GITHUB_WORKSPACE, packageJsonFile), 'utf8');
|
||||||
|
({ packageManager } = packageJsonFile.endsWith(".yaml")
|
||||||
|
? YAML.parse(content, { merge: true })
|
||||||
|
: JSON.parse(content)
|
||||||
|
)
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
// Swallow error if package.json doesn't exist in root
|
// Swallow error if package.json doesn't exist in root
|
||||||
if (!util.types.isNativeError(error) || !('code' in error) || error.code !== 'ENOENT') throw error
|
if (!util.types.isNativeError(error) || !('code' in error) || error.code !== 'ENOENT') throw error
|
||||||
|
|
Loading…
Reference in New Issue
Block a user