WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit f5b1fd3

Browse files
committed
feat: add support for package.json5 format
1 parent 41ff726 commit f5b1fd3

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ If `run_install` is a YAML string representation of either an object or an array
4444

4545
### `package_json_file`
4646

47-
**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.
47+
**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.
4848

4949
### `standalone`
5050

dist/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@types/node": "^20.11.5",
1313
"@types/node-fetch": "^2.6.11",
1414
"expand-tilde": "^2.0.2",
15+
"json5": "^2.2.3",
1516
"yaml": "^2.3.4",
1617
"zod": "^3.22.4"
1718
},

pnpm-lock.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/install-pnpm/run.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { execPath } from 'process'
77
import util from 'util'
88
import { Inputs } from '../inputs'
99
import YAML from 'yaml'
10+
import JSON5 from 'json5'
1011

1112
export async function runSelfInstaller(inputs: Inputs): Promise<number> {
1213
const { version, dest, packageJsonFile, standalone } = inputs
@@ -64,7 +65,7 @@ async function readTarget(opts: {
6465
const content = readFileSync(path.join(GITHUB_WORKSPACE, packageJsonFile), 'utf8');
6566
({ packageManager } = packageJsonFile.endsWith(".yaml")
6667
? YAML.parse(content, { merge: true })
67-
: JSON.parse(content)
68+
: JSON5.parse(content)
6869
)
6970
} catch (error: unknown) {
7071
// Swallow error if package.json doesn't exist in root

0 commit comments

Comments
 (0)