Skip to content

Commit d6ec9f2

Browse files
authored
fix: replace deprecated read-package-json (#1101)
> npm warn deprecated [email protected]: This package is no longer supported. Please use @npmcli/package-json instead.
1 parent fe8af0c commit d6ec9f2

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

lib/package-manager/test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import { join, dirname } from 'path';
2-
import { promisify } from 'util';
32

4-
import readPackageJson from 'read-package-json';
3+
import PackageJson from '@npmcli/package-json';
54
import stripAnsi from 'strip-ansi';
65
import which from 'which';
76

8-
const readPackage = promisify(readPackageJson);
9-
107
import { createOptions } from '../create-options.js';
118
import { spawn } from '../spawn.js';
129
import { timeout } from '../timeout.js';
@@ -32,7 +29,8 @@ export async function test(packageManager, context) {
3229
);
3330
let data;
3431
try {
35-
data = await readPackage(join(wd, 'package.json'), false);
32+
const pkg = await PackageJson.load(wd);
33+
data = pkg.content;
3634
// Explicitly set the version to the value in the downloaded package.json.
3735
context.module.version = data.version;
3836
} catch {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
},
3535
"license": "MIT",
3636
"dependencies": {
37+
"@npmcli/package-json": "^7.0.0",
3738
"async": "^3.2.6",
3839
"bl": "^6.0.16",
3940
"chalk": "^5.4.0",
@@ -44,7 +45,6 @@
4445
"npm-package-arg": "^12.0.1",
4546
"npm-which": "^3.0.1",
4647
"pnpm": "^9.15.1",
47-
"read-package-json": "^7.0.1",
4848
"root-check": "^2.0.0",
4949
"semver": "^7.6.3",
5050
"strip-ansi": "^7.1.0",

0 commit comments

Comments
 (0)