Skip to content

Commit c47a91a

Browse files
committedJan 19, 2024
fix: update code to use @npmcli/run-script
1 parent 64a3503 commit c47a91a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
 

‎lib/run-script.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
const rpj = require('read-package-json-fast')
1+
const PackageJson = require('@npmcli/package-json')
22
const runScriptPkg = require('./run-script-pkg.js')
33
const validateOptions = require('./validate-options.js')
44
const isServerPackage = require('./is-server-package.js')
55

6-
const runScript = options => {
6+
const runScript = async options => {
77
validateOptions(options)
8-
const { pkg, path } = options
9-
return pkg ? runScriptPkg(options)
10-
: rpj(path + '/package.json')
11-
.then(readPackage => runScriptPkg({ ...options, pkg: readPackage }))
8+
if (options.pkg) {
9+
return runScriptPkg(options)
10+
}
11+
const { content: pkg } = await PackageJson.normalize(options.path)
12+
return runScriptPkg({ ...options, pkg })
1213
}
1314

1415
module.exports = Object.assign(runScript, { isServerPackage })

0 commit comments

Comments
 (0)
Please sign in to comment.