diff --git a/README.md b/README.md index 73212a4..2d699c2 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`](https://github.com/pnpm/pnpm/pull/1799)/`package.json5` 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 31c3921..8cd9900 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "@types/node": "^20.11.5", "@types/node-fetch": "^2.6.11", "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 be21d4e..3e1fb8a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,6 +23,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 @@ -90,6 +93,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 + mime-db@1.52.0: resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} engines: {node: '>= 0.6'} @@ -179,6 +187,8 @@ snapshots: dependencies: parse-passwd: 1.0.0 + json5@2.2.3: {} + mime-db@1.52.0: {} mime-types@2.1.35: diff --git a/src/install-pnpm/run.ts b/src/install-pnpm/run.ts index f5b3ae0..bf9b8f5 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,7 +65,7 @@ async function readTarget(opts: { const content = readFileSync(path.join(GITHUB_WORKSPACE, packageJsonFile), 'utf8'); ({ packageManager } = packageJsonFile.endsWith(".yaml") ? YAML.parse(content, { merge: true }) - : JSON.parse(content) + : JSON5.parse(content) ) } catch (error: unknown) { // Swallow error if package.json doesn't exist in root