diff --git a/README.md b/README.md index ac14256..6d8bb23 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,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 425614a..770d72c 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/package.json b/package.json index ddb80fb..bb190f4 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "@types/expand-tilde": "^2.0.2", "@types/node": "^20.11.5", "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 423eda5..527cf8b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,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 @@ -69,6 +72,11 @@ packages: resolution: {integrity: sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==} engines: {node: '>=0.10.0'} + json5@2.2.3: + resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==} + engines: {node: '>=6'} + hasBin: true + parse-passwd@1.0.0: resolution: {integrity: sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q==} engines: {node: '>=0.10.0'} @@ -131,6 +139,8 @@ snapshots: dependencies: parse-passwd: 1.0.0 + json5@2.2.3: {} + parse-passwd@1.0.0: {} pnpm@8.15.9: {} diff --git a/src/install-pnpm/run.ts b/src/install-pnpm/run.ts index f5b3ae0..ed883d5 100644 --- a/src/install-pnpm/run.ts +++ b/src/install-pnpm/run.ts @@ -7,6 +7,7 @@ import { execPath } from 'process' import util from 'util' import { Inputs } from '../inputs' import YAML from 'yaml' +import JSON5 from 'json5' export async function runSelfInstaller(inputs: Inputs): Promise { const { version, dest, packageJsonFile, standalone } = inputs @@ -64,6 +65,8 @@ async function readTarget(opts: { const content = readFileSync(path.join(GITHUB_WORKSPACE, packageJsonFile), 'utf8'); ({ packageManager } = packageJsonFile.endsWith(".yaml") ? YAML.parse(content, { merge: true }) + : packageJsonFile.endsWith(".json5") + ? JSON5.parse(content) : JSON.parse(content) ) } catch (error: unknown) {