diff --git a/.release-please-manifest.json b/.release-please-manifest.json index c6101b7..9695e0e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "9.0.2" + ".": "9.1.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fcf8b2..32d92d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [9.1.0](https://github.com/npm/run-script/compare/v9.0.2...v9.1.0) (2025-03-07) +### Features +* [`21694f2`](https://github.com/npm/run-script/commit/21694f2098d27f3391a137a8885d20b34363faed) [#230](https://github.com/npm/run-script/pull/230) use nodeGyp option (#230) (@wraithgar, @legobeat) +### Chores +* [`fea1ba3`](https://github.com/npm/run-script/commit/fea1ba381afd9ff695ade023634a16024ffdc1d9) [#229](https://github.com/npm/run-script/pull/229) bump @npmcli/template-oss from 4.23.4 to 4.23.5 (#229) (@dependabot[bot], @npm-cli-bot) + ## [9.0.2](https://github.com/npm/run-script/compare/v9.0.1...v9.0.2) (2024-12-04) ### Dependencies * [`74f7e7a`](https://github.com/npm/run-script/commit/74f7e7a87252099fdcb5f516f846061cb9731139) [#227](https://github.com/npm/run-script/pull/227) `node-gyp@11.0.0` (#227) diff --git a/lib/make-spawn-args.js b/lib/make-spawn-args.js index 8a32d71..1c9f02c 100644 --- a/lib/make-spawn-args.js +++ b/lib/make-spawn-args.js @@ -1,21 +1,34 @@ /* eslint camelcase: "off" */ const setPATH = require('./set-path.js') const { resolve } = require('path') -const npm_config_node_gyp = require.resolve('node-gyp/bin/node-gyp.js') + +let npm_config_node_gyp const makeSpawnArgs = options => { const { + args, + binPaths, + cmd, + env, event, + nodeGyp, path, scriptShell = true, - binPaths, - env, stdio, - cmd, - args, stdioString, } = options + if (nodeGyp) { + // npm already pulled this from env and passes it in to options + npm_config_node_gyp = nodeGyp + } else if (env.npm_config_node_gyp) { + // legacy mode for standalone user + npm_config_node_gyp = env.npm_config_node_gyp + } else { + // default + npm_config_node_gyp = require.resolve('node-gyp/bin/node-gyp.js') + } + const spawnEnv = setPATH(path, binPaths, { // we need to at least save the PATH environment var ...process.env, diff --git a/lib/run-script-pkg.js b/lib/run-script-pkg.js index 9900c96..161caeb 100644 --- a/lib/run-script-pkg.js +++ b/lib/run-script-pkg.js @@ -7,18 +7,19 @@ const isServerPackage = require('./is-server-package.js') const runScriptPkg = async options => { const { - event, - path, - scriptShell, + args = [], binPaths = false, env = {}, - stdio = 'pipe', + event, + nodeGyp, + path, pkg, - args = [], - stdioString, + scriptShell, // how long to wait for a process.kill signal // only exposed here so that we can make the test go a bit faster. signalTimeout = 500, + stdio = 'pipe', + stdioString, } = options const { scripts = {}, gypfile } = pkg @@ -63,14 +64,15 @@ const runScriptPkg = async options => { } const [spawnShell, spawnArgs, spawnOpts] = makeSpawnArgs({ + args, + binPaths, + cmd, + env: { ...env, ...packageEnvs(pkg) }, event, + nodeGyp, path, scriptShell, - binPaths, - env: { ...env, ...packageEnvs(pkg) }, stdio, - cmd, - args, stdioString, }) diff --git a/package.json b/package.json index 38a2ac9..6003a73 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/run-script", - "version": "9.0.2", + "version": "9.1.0", "description": "Run a lifecycle script for a package (descendant of npm-lifecycle)", "author": "GitHub Inc.", "license": "ISC", @@ -16,7 +16,7 @@ }, "devDependencies": { "@npmcli/eslint-config": "^5.0.0", - "@npmcli/template-oss": "4.23.4", + "@npmcli/template-oss": "4.24.1", "spawk": "^1.8.1", "tap": "^16.0.1" }, @@ -42,7 +42,7 @@ }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.23.4", + "version": "4.24.1", "publish": "true" }, "tap": { diff --git a/release-please-config.json b/release-please-config.json index a1676b9..c56fd1d 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -33,5 +33,5 @@ "package-name": "" } }, - "prerelease-type": "pre" + "prerelease-type": "pre.0" } diff --git a/test/make-spawn-args.js b/test/make-spawn-args.js index 83e90a0..110f28f 100644 --- a/test/make-spawn-args.js +++ b/test/make-spawn-args.js @@ -62,13 +62,15 @@ t.test('spawn args', async t => { /.*/, a => a.includes('echo test'), e => { - return e.env.test_fixture === 'a string' + return e.env.test_fixture === 'a string' && + e.env.npm_config_node_gyp === '/test/path.js' } ) await t.resolves(() => runScript({ pkg, path: testdir, env: { + npm_config_node_gyp: '/test/path.js', test_fixture: 'a string', }, event: 'test', @@ -76,6 +78,23 @@ t.test('spawn args', async t => { t.ok(spawk.done()) }) + await t.test('provided options.nodeGyp', async t => { + spawk.spawn( + /.*/, + a => a.includes('echo test'), + e => { + return e.env.npm_config_node_gyp === '/test/path.js' + } + ) + await t.resolves(() => runScript({ + pkg, + path: testdir, + nodeGyp: '/test/path.js', + event: 'test', + })) + t.ok(spawk.done()) + }) + await t.test('provided args', async t => { spawk.spawn( /.*/,
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: