diff --git a/README.md b/README.md index 6a7540e..79ac827 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ If `run_install` is a YAML string representation of either an object or an array ### `package_json_file` -**Optional** (_type:_ `string`, _default:_ `package.json`) File path to the `package.json`/[`package.yaml`](https://github.com/pnpm/pnpm/pull/1799) to read "packageManager" configuration. +**Optional** (_type:_ `string`, _default:_ `package.json`) File path to the `package.json`/[`package.yaml`/`package.json5`](https://github.com/pnpm/pnpm/pull/1799) to read "packageManager" configuration. ### `standalone` diff --git a/dist/index.js b/dist/index.js index ff2b4d9..51eb030 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/package.json b/package.json index 991c379..1d5a7f0 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@types/expand-tilde": "^2.0.2", "@types/node": "^22.0.0", "expand-tilde": "^2.0.2", + "json5": "^2.2.3", "yaml": "^2.3.4", "zod": "^3.22.4" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c3b580b..704465f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,6 +29,9 @@ importers: expand-tilde: specifier: ^2.0.2 version: 2.0.2 + json5: + specifier: ^2.2.3 + version: 2.2.3 yaml: specifier: ^2.3.4 version: 2.7.0 @@ -422,6 +425,11 @@ packages: resolution: {integrity: sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==} engines: {node: '>= 14'} + json5@2.2.3: + resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==} + engines: {node: '>=6'} + hasBin: true + math-intrinsics@1.1.0: resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} engines: {node: '>= 0.4'} @@ -931,6 +939,8 @@ snapshots: transitivePeerDependencies: - supports-color + json5@2.2.3: {} + math-intrinsics@1.1.0: {} mime-db@1.52.0: {} diff --git a/src/install-pnpm/run.ts b/src/install-pnpm/run.ts index 1a847af..0b8dc2b 100644 --- a/src/install-pnpm/run.ts +++ b/src/install-pnpm/run.ts @@ -6,6 +6,7 @@ import path from 'path' import util from 'util' import { Inputs } from '../inputs' import { parse as parseYaml } from 'yaml' +import JSON5 from 'json5' import pnpmLock from './bootstrap/pnpm-lock.json' import exeLock from './bootstrap/exe-lock.json' @@ -93,6 +94,8 @@ function readTargetVersion(opts: { const content = readFileSync(path.join(GITHUB_WORKSPACE, packageJsonFile), 'utf8'); const manifest = packageJsonFile.endsWith(".yaml") ? parseYaml(content, { merge: true }) + : packageJsonFile.endsWith(".json5") + ? JSON5.parse(content) : JSON.parse(content) packageManager = manifest.packageManager devEngines = manifest.devEngines