diff --git a/docs/lib/content/commands/npm-exec.md b/docs/lib/content/commands/npm-exec.md index 33fc1a08248ac..ad11efb9a1807 100644 --- a/docs/lib/content/commands/npm-exec.md +++ b/docs/lib/content/commands/npm-exec.md @@ -274,7 +274,7 @@ project. ### See Also -* [npm run-script](/commands/npm-run-script) +* [npm run](/commands/npm-run) * [npm scripts](/using-npm/scripts) * [npm test](/commands/npm-test) * [npm start](/commands/npm-start) diff --git a/docs/lib/content/commands/npm-restart.md b/docs/lib/content/commands/npm-restart.md index c337ed6456b95..e1574ca18deca 100644 --- a/docs/lib/content/commands/npm-restart.md +++ b/docs/lib/content/commands/npm-restart.md @@ -10,7 +10,7 @@ description: Restart a package ### Description -This restarts a project. It is equivalent to running `npm run-script +This restarts a project. It is equivalent to running `npm run restart`. If the current project has a `"restart"` script specified in @@ -38,7 +38,7 @@ If it does _not_ have a `"restart"` script specified, but it does have ### See Also -* [npm run-script](/commands/npm-run-script) +* [npm run](/commands/npm-run) * [npm scripts](/using-npm/scripts) * [npm test](/commands/npm-test) * [npm start](/commands/npm-start) diff --git a/docs/lib/content/commands/npm-run-script.md b/docs/lib/content/commands/npm-run.md similarity index 99% rename from docs/lib/content/commands/npm-run-script.md rename to docs/lib/content/commands/npm-run.md index 3c35a4778d687..9ed4e73aafa8f 100644 --- a/docs/lib/content/commands/npm-run-script.md +++ b/docs/lib/content/commands/npm-run.md @@ -1,5 +1,5 @@ --- -title: npm-run-script +title: npm-run section: 1 description: Run arbitrary package scripts --- diff --git a/docs/lib/content/commands/npm-shrinkwrap.md b/docs/lib/content/commands/npm-shrinkwrap.md index 8717a63f3fb16..dde762d40d43a 100644 --- a/docs/lib/content/commands/npm-shrinkwrap.md +++ b/docs/lib/content/commands/npm-shrinkwrap.md @@ -20,7 +20,7 @@ design and purpose of package locks in npm, see ### See Also * [npm install](/commands/npm-install) -* [npm run-script](/commands/npm-run-script) +* [npm run](/commands/npm-run) * [npm scripts](/using-npm/scripts) * [package.json](/configuring-npm/package-json) * [package-lock.json](/configuring-npm/package-lock-json) diff --git a/docs/lib/content/commands/npm-start.md b/docs/lib/content/commands/npm-start.md index c30dda963e9d6..b3ab6cf2b745a 100644 --- a/docs/lib/content/commands/npm-start.md +++ b/docs/lib/content/commands/npm-start.md @@ -21,7 +21,7 @@ the file specified in a package's `"main"` attribute when evoking with `node .` As of [`npm@2.0.0`](https://blog.npmjs.org/post/98131109725/npm-2-0-0), you can -use custom arguments when executing scripts. Refer to [`npm run-script`](/commands/npm-run-script) for more details. +use custom arguments when executing scripts. Refer to [`npm run`](/commands/npm-run) for more details. ### Example @@ -49,7 +49,7 @@ npm start ### See Also -* [npm run-script](/commands/npm-run-script) +* [npm run](/commands/npm-run) * [npm scripts](/using-npm/scripts) * [npm test](/commands/npm-test) * [npm restart](/commands/npm-restart) diff --git a/docs/lib/content/commands/npm-stop.md b/docs/lib/content/commands/npm-stop.md index e4924d44821ea..05c9c556ac734 100644 --- a/docs/lib/content/commands/npm-stop.md +++ b/docs/lib/content/commands/npm-stop.md @@ -42,7 +42,7 @@ npm stop ### See Also -* [npm run-script](/commands/npm-run-script) +* [npm run](/commands/npm-run) * [npm scripts](/using-npm/scripts) * [npm test](/commands/npm-test) * [npm start](/commands/npm-start) diff --git a/docs/lib/content/commands/npm-test.md b/docs/lib/content/commands/npm-test.md index 11a4d793aa8da..58a35e5bba1d2 100644 --- a/docs/lib/content/commands/npm-test.md +++ b/docs/lib/content/commands/npm-test.md @@ -37,7 +37,7 @@ npm test ### See Also -* [npm run-script](/commands/npm-run-script) +* [npm run](/commands/npm-run) * [npm scripts](/using-npm/scripts) * [npm start](/commands/npm-start) * [npm restart](/commands/npm-restart) diff --git a/docs/lib/content/commands/npm-version.md b/docs/lib/content/commands/npm-version.md index 08e74ef307afd..a5167cd0dd3be 100644 --- a/docs/lib/content/commands/npm-version.md +++ b/docs/lib/content/commands/npm-version.md @@ -98,7 +98,7 @@ deletes the `build/temp` directory. ### See Also * [npm init](/commands/npm-init) -* [npm run-script](/commands/npm-run-script) +* [npm run](/commands/npm-run) * [npm scripts](/using-npm/scripts) * [package.json](/configuring-npm/package-json) * [config](/using-npm/config) diff --git a/docs/lib/content/commands/npx.md b/docs/lib/content/commands/npx.md index ca72b3e03bdae..88ac18d7eba7c 100644 --- a/docs/lib/content/commands/npx.md +++ b/docs/lib/content/commands/npx.md @@ -153,7 +153,7 @@ This resulted in some shifts in its functionality: ### See Also -* [npm run-script](/commands/npm-run-script) +* [npm run](/commands/npm-run) * [npm scripts](/using-npm/scripts) * [npm test](/commands/npm-test) * [npm start](/commands/npm-start) diff --git a/docs/lib/content/configuring-npm/package-json.md b/docs/lib/content/configuring-npm/package-json.md index 381b9aef46861..e69a867dae51b 100644 --- a/docs/lib/content/configuring-npm/package-json.md +++ b/docs/lib/content/configuring-npm/package-json.md @@ -378,7 +378,7 @@ file in the `bin` field, so it is available to run by `name` or `name.cmd` (on Windows PowerShell). When this package is installed as a dependency in another package, the file will be linked where it will be available to that package either directly by `npm exec` or by name in other scripts when invoking them -via `npm run-script`. +via `npm run`. For example, myapp could have this: diff --git a/docs/lib/content/nav.yml b/docs/lib/content/nav.yml index 4148c4533efcb..f6f8014f28071 100644 --- a/docs/lib/content/nav.yml +++ b/docs/lib/content/nav.yml @@ -144,8 +144,8 @@ - title: npm root url: /commands/npm-root description: Display npm root - - title: npm run-script - url: /commands/npm-run-script + - title: npm run + url: /commands/npm-run description: Run arbitrary package scripts - title: npm sbom url: /commands/npm-sbom diff --git a/docs/lib/content/using-npm/scripts.md b/docs/lib/content/using-npm/scripts.md index 0e2303f384d01..48cb2eb1c9f4c 100644 --- a/docs/lib/content/using-npm/scripts.md +++ b/docs/lib/content/using-npm/scripts.md @@ -9,7 +9,7 @@ description: How npm handles the "scripts" field The `"scripts"` property of your `package.json` file supports a number of built-in scripts and their preset life cycle events as well as arbitrary scripts. These all can be executed by running -`npm run-script ` or `npm run ` for short. *Pre* and *post* +`npm run ` or `npm run ` for short. *Pre* and *post* commands with matching names will be run for those as well (e.g. `premyscript`, `myscript`, `postmyscript`). Scripts from dependencies can be run with `npm explore -- npm run `. @@ -180,7 +180,7 @@ If there is a `restart` script defined, these events are run, otherwise * `restart` * `postrestart` -#### [`npm run `](/commands/npm-run-script) +#### [`npm run `](/commands/npm-run) * `pre` * `` @@ -358,7 +358,7 @@ file. ### See Also -* [npm run-script](/commands/npm-run-script) +* [npm run](/commands/npm-run) * [package.json](/configuring-npm/package-json) * [npm developers](/using-npm/developers) * [npm install](/commands/npm-install) diff --git a/docs/lib/content/using-npm/workspaces.md b/docs/lib/content/using-npm/workspaces.md index cb545c0b46bf1..34819b801e5fb 100644 --- a/docs/lib/content/using-npm/workspaces.md +++ b/docs/lib/content/using-npm/workspaces.md @@ -221,6 +221,6 @@ npm run test --workspaces --if-present * [npm install](/commands/npm-install) * [npm publish](/commands/npm-publish) -* [npm run-script](/commands/npm-run-script) +* [npm run](/commands/npm-run) * [config](/using-npm/config) diff --git a/lib/commands/restart.js b/lib/commands/restart.js index 7ca2eb323da3c..52b9b20757e29 100644 --- a/lib/commands/restart.js +++ b/lib/commands/restart.js @@ -1,6 +1,6 @@ const LifecycleCmd = require('../lifecycle-cmd.js') -// This ends up calling run-script(['restart', ...args]) +// This ends up calling run(['restart', ...args]) class Restart extends LifecycleCmd { static description = 'Restart a package' static name = 'restart' diff --git a/lib/commands/run-script.js b/lib/commands/run.js similarity index 98% rename from lib/commands/run-script.js rename to lib/commands/run.js index 9789af575dcce..d89cb4d93bb7f 100644 --- a/lib/commands/run-script.js +++ b/lib/commands/run.js @@ -16,7 +16,7 @@ class RunScript extends BaseCommand { 'script-shell', ] - static name = 'run-script' + static name = 'run' static usage = [' [-- ]'] static workspaces = true static ignoreImplicitWorkspace = false @@ -201,7 +201,7 @@ class RunScript extends BaseCommand { } if (runScripts.length) { - const via = `via \`${blue('npm run-script')}\`:` + const via = `via \`${blue('npm run')}\`:` if (!cmds.length) { output.standard(`${title('Scripts')} available ${pkgId} ${via}`) } else { diff --git a/lib/commands/start.js b/lib/commands/start.js index a16eade24d21e..54818c5be4da6 100644 --- a/lib/commands/start.js +++ b/lib/commands/start.js @@ -1,6 +1,6 @@ const LifecycleCmd = require('../lifecycle-cmd.js') -// This ends up calling run-script(['start', ...args]) +// This ends up calling run(['start', ...args]) class Start extends LifecycleCmd { static description = 'Start a package' static name = 'start' diff --git a/lib/commands/stop.js b/lib/commands/stop.js index ae3031f06dd96..e6e9c9afca1dd 100644 --- a/lib/commands/stop.js +++ b/lib/commands/stop.js @@ -1,6 +1,6 @@ const LifecycleCmd = require('../lifecycle-cmd.js') -// This ends up calling run-script(['stop', ...args]) +// This ends up calling run(['stop', ...args]) class Stop extends LifecycleCmd { static description = 'Stop a package' static name = 'stop' diff --git a/lib/commands/test.js b/lib/commands/test.js index eccc47fc3341c..7dbff0b0b69c2 100644 --- a/lib/commands/test.js +++ b/lib/commands/test.js @@ -1,6 +1,6 @@ const LifecycleCmd = require('../lifecycle-cmd.js') -// This ends up calling run-script(['test', ...args]) +// This ends up calling run(['test', ...args]) class Test extends LifecycleCmd { static description = 'Test a package' static name = 'test' diff --git a/lib/lifecycle-cmd.js b/lib/lifecycle-cmd.js index a509a9380f668..eb3cc1c9beed7 100644 --- a/lib/lifecycle-cmd.js +++ b/lib/lifecycle-cmd.js @@ -9,11 +9,11 @@ class LifecycleCmd extends BaseCommand { static ignoreImplicitWorkspace = false async exec (args) { - return this.npm.exec('run-script', [this.constructor.name, ...args]) + return this.npm.exec('run', [this.constructor.name, ...args]) } async execWorkspaces (args) { - return this.npm.exec('run-script', [this.constructor.name, ...args]) + return this.npm.exec('run', [this.constructor.name, ...args]) } } diff --git a/lib/npm.js b/lib/npm.js index 85f175fb902f3..9a7103f135d5d 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -221,7 +221,7 @@ class Npm { const command = new Command(this) // since 'test', 'start', 'stop', etc. commands re-enter this function - // to call the run-script command, we need to only set it one time. + // to call the run command, we need to only set it one time. if (!this.#command) { this.#command = command process.env.npm_command = this.command diff --git a/lib/utils/cmd-list.js b/lib/utils/cmd-list.js index 96eb0974a2ed3..61f64f77678e2 100644 --- a/lib/utils/cmd-list.js +++ b/lib/utils/cmd-list.js @@ -50,7 +50,7 @@ const commands = [ 'repo', 'restart', 'root', - 'run-script', + 'run', 'sbom', 'search', 'set', @@ -105,7 +105,7 @@ const aliases = { t: 'test', ddp: 'dedupe', v: 'view', - run: 'run-script', + 'run-script': 'run', 'clean-install': 'ci', 'clean-install-test': 'install-ci-test', x: 'exec', @@ -132,9 +132,9 @@ const aliases = { 'dist-tags': 'dist-tag', upgrade: 'update', udpate: 'update', - rum: 'run-script', + rum: 'run', sit: 'install-ci-test', - urn: 'run-script', + urn: 'run', ogr: 'org', 'add-user': 'adduser', } diff --git a/smoke-tests/tap-snapshots/test/index.js.test.cjs b/smoke-tests/tap-snapshots/test/index.js.test.cjs index 9f27bde435f14..b9b287f3ad18d 100644 --- a/smoke-tests/tap-snapshots/test/index.js.test.cjs +++ b/smoke-tests/tap-snapshots/test/index.js.test.cjs @@ -27,10 +27,9 @@ All commands: help-search, init, install, install-ci-test, install-test, link, ll, login, logout, ls, org, outdated, owner, pack, ping, pkg, prefix, profile, prune, publish, query, rebuild, - repo, restart, root, run-script, sbom, search, set, - shrinkwrap, star, stars, start, stop, team, test, token, - undeprecate, uninstall, unpublish, unstar, update, version, - view, whoami + repo, restart, root, run, sbom, search, set, shrinkwrap, + star, stars, start, stop, team, test, token, undeprecate, + uninstall, unpublish, unstar, update, version, view, whoami Specify configs in the ini-formatted file: {NPM}/{TESTDIR}/home/.npmrc @@ -355,7 +354,7 @@ exports[`test/index.js TAP basic npm prefix > should have expected prefix output {NPM}/{TESTDIR}/project ` -exports[`test/index.js TAP basic npm run-script > should have expected run-script output 1`] = ` +exports[`test/index.js TAP basic npm run > should have expected run output 1`] = ` > project@1.0.0 hello > echo Hello diff --git a/smoke-tests/test/index.js b/smoke-tests/test/index.js index 48ab12ea98e53..0daf28ae9bf6c 100644 --- a/smoke-tests/test/index.js +++ b/smoke-tests/test/index.js @@ -182,10 +182,10 @@ t.test('basic', async t => { ) }) - await t.test('npm run-script', async t => { - const cmdRes = await npm('run', 'hello') + await t.test('npm run', async t => { + const cmdRes = await npm('run-script', 'hello') - t.matchSnapshot(cmdRes.stdout, 'should have expected run-script output') + t.matchSnapshot(cmdRes.stdout, 'should have expected run output') }) await t.test('npm prefix', async t => { diff --git a/tap-snapshots/test/lib/commands/completion.js.test.cjs b/tap-snapshots/test/lib/commands/completion.js.test.cjs index a281883539f61..64759ec6ef9cf 100644 --- a/tap-snapshots/test/lib/commands/completion.js.test.cjs +++ b/tap-snapshots/test/lib/commands/completion.js.test.cjs @@ -88,7 +88,7 @@ Array [ repo restart root - run-script + run sbom search set @@ -135,7 +135,7 @@ Array [ t ddp v - run + run-script clean-install clean-install-test x diff --git a/tap-snapshots/test/lib/commands/publish.js.test.cjs b/tap-snapshots/test/lib/commands/publish.js.test.cjs index 4d3606b93bfa6..71ea8c025e9a5 100644 --- a/tap-snapshots/test/lib/commands/publish.js.test.cjs +++ b/tap-snapshots/test/lib/commands/publish.js.test.cjs @@ -197,7 +197,7 @@ Object { "man/man1/npm-repo.1", "man/man1/npm-restart.1", "man/man1/npm-root.1", - "man/man1/npm-run-script.1", + "man/man1/npm-run.1", "man/man1/npm-sbom.1", "man/man1/npm-search.1", "man/man1/npm-shrinkwrap.1", diff --git a/tap-snapshots/test/lib/commands/run.js.test.cjs b/tap-snapshots/test/lib/commands/run.js.test.cjs new file mode 100644 index 0000000000000..367415db8fe07 --- /dev/null +++ b/tap-snapshots/test/lib/commands/run.js.test.cjs @@ -0,0 +1,274 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/lib/commands/run.js TAP list scripts no args > basic report 1`] = ` +Lifecycle scripts included in x@1.2.3: + test + exit 2 + start + node server.js + stop + node kill-server.js +available via \`npm run\`: + preenv + echo before the env + postenv + echo after the env +` + +exports[`test/lib/commands/run.js TAP list scripts parseable > must match snapshot 1`] = ` +test:exit 2 +start:node server.js +stop:node kill-server.js +preenv:echo before the env +postenv:echo after the env +` + +exports[`test/lib/commands/run.js TAP list scripts warn json > json report 1`] = ` +{ + "test": "exit 2", + "start": "node server.js", + "stop": "node kill-server.js", + "preenv": "echo before the env", + "postenv": "echo after the env" +} +` + +exports[`test/lib/commands/run.js TAP list scripts, only commands > must match snapshot 1`] = ` +Lifecycle scripts included in x@1.2.3: + preversion + echo doing the version dance +` + +exports[`test/lib/commands/run.js TAP list scripts, only non-commands > must match snapshot 1`] = ` +Scripts available in x@1.2.3 via \`npm run\`: + glorp + echo doing the glerp glop +` + +exports[`test/lib/commands/run.js TAP workspaces failed workspace run with succeeded runs > should log error msgs for each workspace script 1`] = ` +Lifecycle script \`glorp\` failed with error: +code ERR +workspace a@1.0.0 +location {CWD}/prefix/packages/a +ERR +` + +exports[`test/lib/commands/run.js TAP workspaces list all scripts --json > must match snapshot 1`] = ` +{ + "a": { + "glorp": "echo a doing the glerp glop" + }, + "b": { + "glorp": "echo b doing the glerp glop" + }, + "c": { + "test": "exit 0", + "posttest": "echo posttest", + "lorem": "echo c lorem" + }, + "d": { + "test": "exit 0", + "posttest": "echo posttest" + }, + "e": { + "test": "exit 0", + "start": "echo start something" + }, + "noscripts": {} +} +` + +exports[`test/lib/commands/run.js TAP workspaces list all scripts --parseable > must match snapshot 1`] = ` +a:glorp:echo a doing the glerp glop +b:glorp:echo b doing the glerp glop +c:test:exit 0 +c:posttest:echo posttest +c:lorem:echo c lorem +d:test:exit 0 +d:posttest:echo posttest +e:test:exit 0 +e:start:echo start something +` + +exports[`test/lib/commands/run.js TAP workspaces list all scripts > must match snapshot 1`] = ` +Scripts available in a@1.0.0 via \`npm run\`: + glorp + echo a doing the glerp glop + +Scripts available in b@2.0.0 via \`npm run\`: + glorp + echo b doing the glerp glop + +Lifecycle scripts included in c@1.0.0: + test + exit 0 + posttest + echo posttest +available via \`npm run\`: + lorem + echo c lorem + +Lifecycle scripts included in d@1.0.0: + test + exit 0 + posttest + echo posttest + +Lifecycle scripts included in e: + test + exit 0 + start + echo start something +` + +exports[`test/lib/commands/run.js TAP workspaces list all scripts with colors > must match snapshot 1`] = ` +Scripts available in a@1.0.0 via \`npm run\`: + glorp + echo a doing the glerp glop + +Scripts available in b@2.0.0 via \`npm run\`: + glorp + echo b doing the glerp glop + +Lifecycle scripts included in c@1.0.0: + test + exit 0 + posttest + echo posttest +available via \`npm run\`: + lorem + echo c lorem + +Lifecycle scripts included in d@1.0.0: + test + exit 0 + posttest + echo posttest + +Lifecycle scripts included in e: + test + exit 0 + start + echo start something +` + +exports[`test/lib/commands/run.js TAP workspaces list regular scripts, filtered by name > must match snapshot 1`] = ` +Scripts available in a@1.0.0 via \`npm run\`: + glorp + echo a doing the glerp glop + +Scripts available in b@2.0.0 via \`npm run\`: + glorp + echo b doing the glerp glop +` + +exports[`test/lib/commands/run.js TAP workspaces list regular scripts, filtered by parent folder > must match snapshot 1`] = ` +Scripts available in a@1.0.0 via \`npm run\`: + glorp + echo a doing the glerp glop + +Scripts available in b@2.0.0 via \`npm run\`: + glorp + echo b doing the glerp glop + +Lifecycle scripts included in c@1.0.0: + test + exit 0 + posttest + echo posttest +available via \`npm run\`: + lorem + echo c lorem + +Lifecycle scripts included in d@1.0.0: + test + exit 0 + posttest + echo posttest + +Lifecycle scripts included in e: + test + exit 0 + start + echo start something +` + +exports[`test/lib/commands/run.js TAP workspaces list regular scripts, filtered by path > must match snapshot 1`] = ` +Scripts available in a@1.0.0 via \`npm run\`: + glorp + echo a doing the glerp glop +` + +exports[`test/lib/commands/run.js TAP workspaces missing scripts in all workspaces > should log error msgs for each workspace script 1`] = ` +Lifecycle script \`missing-script\` failed with error: +workspace a@1.0.0 +location {CWD}/prefix/packages/a +Missing script: "missing-script" +npm error +To see a list of scripts, run: + npm run --workspace=a@1.0.0 +Lifecycle script \`missing-script\` failed with error: +workspace b@2.0.0 +location {CWD}/prefix/packages/b +Missing script: "missing-script" +npm error +To see a list of scripts, run: + npm run --workspace=b@2.0.0 +Lifecycle script \`missing-script\` failed with error: +workspace c@1.0.0 +location {CWD}/prefix/packages/c +Missing script: "missing-script" +npm error +To see a list of scripts, run: + npm run --workspace=c@1.0.0 +Lifecycle script \`missing-script\` failed with error: +workspace d@1.0.0 +location {CWD}/prefix/packages/d +Missing script: "missing-script" +npm error +To see a list of scripts, run: + npm run --workspace=d@1.0.0 +Lifecycle script \`missing-script\` failed with error: +workspace e +location {CWD}/prefix/packages/e +Missing script: "missing-script" +npm error +To see a list of scripts, run: + npm run --workspace=e +Lifecycle script \`missing-script\` failed with error: +workspace noscripts@1.0.0 +location {CWD}/prefix/packages/noscripts +Missing script: "missing-script" +npm error +To see a list of scripts, run: + npm run --workspace=noscripts@1.0.0 +` + +exports[`test/lib/commands/run.js TAP workspaces missing scripts in some workspaces > should log error msgs for each workspace script 1`] = ` +Lifecycle script \`test\` failed with error: +workspace a@1.0.0 +location {CWD}/prefix/packages/a +Missing script: "test" +npm error +To see a list of scripts, run: + npm run --workspace=a@1.0.0 +Lifecycle script \`test\` failed with error: +workspace b@2.0.0 +location {CWD}/prefix/packages/b +Missing script: "test" +npm error +To see a list of scripts, run: + npm run --workspace=b@2.0.0 +` + +exports[`test/lib/commands/run.js TAP workspaces single failed workspace run > should log error msgs for each workspace script 1`] = ` +Lifecycle script \`test\` failed with error: +workspace c@1.0.0 +location {CWD}/prefix/packages/c +err +` diff --git a/tap-snapshots/test/lib/docs.js.test.cjs b/tap-snapshots/test/lib/docs.js.test.cjs index c78807fc73468..f03284c9b9b81 100644 --- a/tap-snapshots/test/lib/docs.js.test.cjs +++ b/tap-snapshots/test/lib/docs.js.test.cjs @@ -73,8 +73,8 @@ Object { "rb": "rebuild", "remove": "uninstall", "rm": "uninstall", - "rum": "run-script", - "run": "run-script", + "rum": "run", + "run-script": "run", "s": "search", "se": "search", "show": "view", @@ -86,7 +86,7 @@ Object { "unlink": "uninstall", "up": "update", "upgrade": "update", - "urn": "run-script", + "urn": "run", "v": "view", "verison": "version", "why": "explain", @@ -143,7 +143,7 @@ Array [ "repo", "restart", "root", - "run-script", + "run", "sbom", "search", "set", @@ -743,10 +743,10 @@ library. * Default: false * Type: Boolean -If true, npm will not exit with an error code when \`run-script\` is invoked -for a script that isn't defined in the \`scripts\` section of \`package.json\`. -This option can be used when it's desirable to optionally run a script when -it's present and fail if the script fails. This is useful, for example, when +If true, npm will not exit with an error code when \`run\` is invoked for a +script that isn't defined in the \`scripts\` section of \`package.json\`. This +option can be used when it's desirable to optionally run a script when it's +present and fail if the script fails. This is useful, for example, when running scripts that may only apply for some builds in an otherwise generic CI setup. @@ -760,9 +760,9 @@ This value is not exported to the environment for child processes. If true, npm does not run scripts specified in package.json files. Note that commands explicitly intended to run a particular script, such as -\`npm start\`, \`npm stop\`, \`npm restart\`, \`npm test\`, and \`npm run-script\` -will still run their intended script if \`ignore-scripts\` is set, but they -will *not* run any pre- or post-scripts. +\`npm start\`, \`npm stop\`, \`npm restart\`, \`npm test\`, and \`npm run\` will still +run their intended script if \`ignore-scripts\` is set, but they will *not* +run any pre- or post-scripts. @@ -4016,25 +4016,25 @@ Note: This command is unaware of workspaces. #### \`global\` ` -exports[`test/lib/docs.js TAP usage run-script > must match snapshot 1`] = ` +exports[`test/lib/docs.js TAP usage run > must match snapshot 1`] = ` Run arbitrary package scripts Usage: -npm run-script [-- ] +npm run [-- ] Options: [-w|--workspace [-w|--workspace ...]] [--workspaces] [--include-workspace-root] [--if-present] [--ignore-scripts] [--foreground-scripts] [--script-shell ] -aliases: run, rum, urn +aliases: run-script, rum, urn -Run "npm help run-script" for more info +Run "npm help run" for more info \`\`\`bash -npm run-script [-- ] +npm run [-- ] -aliases: run, rum, urn +aliases: run-script, rum, urn \`\`\` #### \`workspace\` diff --git a/tap-snapshots/test/lib/npm.js.test.cjs b/tap-snapshots/test/lib/npm.js.test.cjs index 88597c2fd15f6..ca42f13356278 100644 --- a/tap-snapshots/test/lib/npm.js.test.cjs +++ b/tap-snapshots/test/lib/npm.js.test.cjs @@ -37,10 +37,9 @@ All commands: help-search, init, install, install-ci-test, install-test, link, ll, login, logout, ls, org, outdated, owner, pack, ping, pkg, prefix, profile, prune, publish, query, rebuild, - repo, restart, root, run-script, sbom, search, set, - shrinkwrap, star, stars, start, stop, team, test, token, - undeprecate, uninstall, unpublish, unstar, update, version, - view, whoami + repo, restart, root, run, sbom, search, set, shrinkwrap, + star, stars, start, stop, team, test, token, undeprecate, + uninstall, unpublish, unstar, update, version, view, whoami Specify configs in the ini-formatted file: {USERCONFIG} @@ -85,15 +84,14 @@ All commands: ping, pkg, prefix, profile, prune, publish, query, rebuild, repo, - restart, root, - run-script, sbom, - search, set, shrinkwrap, - star, stars, start, - stop, team, test, token, - undeprecate, uninstall, - unpublish, unstar, - update, version, view, - whoami + restart, root, run, + sbom, search, set, + shrinkwrap, star, stars, + start, stop, team, test, + token, undeprecate, + uninstall, unpublish, + unstar, update, version, + view, whoami Specify configs in the ini-formatted file: {USERCONFIG} @@ -138,15 +136,14 @@ All commands: ping, pkg, prefix, profile, prune, publish, query, rebuild, repo, - restart, root, - run-script, sbom, - search, set, shrinkwrap, - star, stars, start, - stop, team, test, token, - undeprecate, uninstall, - unpublish, unstar, - update, version, view, - whoami + restart, root, run, + sbom, search, set, + shrinkwrap, star, stars, + start, stop, team, test, + token, undeprecate, + uninstall, unpublish, + unstar, update, version, + view, whoami Specify configs in the ini-formatted file: {USERCONFIG} @@ -180,10 +177,9 @@ All commands: help-search, init, install, install-ci-test, install-test, link, ll, login, logout, ls, org, outdated, owner, pack, ping, pkg, prefix, profile, prune, publish, query, rebuild, - repo, restart, root, run-script, sbom, search, set, - shrinkwrap, star, stars, start, stop, team, test, token, - undeprecate, uninstall, unpublish, unstar, update, version, - view, whoami + repo, restart, root, run, sbom, search, set, shrinkwrap, + star, stars, start, stop, team, test, token, undeprecate, + uninstall, unpublish, unstar, update, version, view, whoami Specify configs in the ini-formatted file: {USERCONFIG} @@ -228,15 +224,14 @@ All commands: ping, pkg, prefix, profile, prune, publish, query, rebuild, repo, - restart, root, - run-script, sbom, - search, set, shrinkwrap, - star, stars, start, - stop, team, test, token, - undeprecate, uninstall, - unpublish, unstar, - update, version, view, - whoami + restart, root, run, + sbom, search, set, + shrinkwrap, star, stars, + start, stop, team, test, + token, undeprecate, + uninstall, unpublish, + unstar, update, version, + view, whoami Specify configs in the ini-formatted file: {USERCONFIG} @@ -281,15 +276,14 @@ All commands: ping, pkg, prefix, profile, prune, publish, query, rebuild, repo, - restart, root, - run-script, sbom, - search, set, shrinkwrap, - star, stars, start, - stop, team, test, token, - undeprecate, uninstall, - unpublish, unstar, - update, version, view, - whoami + restart, root, run, + sbom, search, set, + shrinkwrap, star, stars, + start, stop, team, test, + token, undeprecate, + uninstall, unpublish, + unstar, update, version, + view, whoami Specify configs in the ini-formatted file: {USERCONFIG} @@ -333,14 +327,14 @@ All commands: ping, pkg, prefix, profile, prune, publish, query, rebuild, repo, - restart, root, - run-script, sbom, search, - set, shrinkwrap, star, - stars, start, stop, team, - test, token, undeprecate, - uninstall, unpublish, - unstar, update, version, - view, whoami + restart, root, run, sbom, + search, set, shrinkwrap, + star, stars, start, stop, + team, test, token, + undeprecate, uninstall, + unpublish, unstar, + update, version, view, + whoami Specify configs in the ini-formatted file: {USERCONFIG} @@ -374,10 +368,10 @@ All commands: help-search, init, install, install-ci-test, install-test, link, ll, login, logout, ls, org, outdated, owner, pack, ping, pkg, prefix, profile, prune, publish, query, rebuild, - repo, restart, root, run-script, sbom, search, set, - shrinkwrap, star, stars, start, stop, team, test, token, - undeprecate, uninstall, unpublish, unstar, update, version, - view, whoami + repo, restart, root, run, sbom, search, set, shrinkwrap, + star, stars, start, stop, team, test, token, undeprecate, + uninstall, unpublish, unstar, update, version, view, + whoami Specify configs in the ini-formatted file: {USERCONFIG} @@ -411,10 +405,9 @@ All commands: help-search, init, install, install-ci-test, install-test, link, ll, login, logout, ls, org, outdated, owner, pack, ping, pkg, prefix, profile, prune, publish, query, rebuild, - repo, restart, root, run-script, sbom, search, set, - shrinkwrap, star, stars, start, stop, team, test, token, - undeprecate, uninstall, unpublish, unstar, update, version, - view, whoami + repo, restart, root, run, sbom, search, set, shrinkwrap, + star, stars, start, stop, team, test, token, undeprecate, + uninstall, unpublish, unstar, update, version, view, whoami Specify configs in the ini-formatted file: {USERCONFIG} @@ -448,10 +441,9 @@ All commands: help-search, init, install, install-ci-test, install-test, link, ll, login, logout, ls, org, outdated, owner, pack, ping, pkg, prefix, profile, prune, publish, query, rebuild, - repo, restart, root, run-script, sbom, search, set, - shrinkwrap, star, stars, start, stop, team, test, token, - undeprecate, uninstall, unpublish, unstar, update, version, - view, whoami + repo, restart, root, run, sbom, search, set, shrinkwrap, + star, stars, start, stop, team, test, token, undeprecate, + uninstall, unpublish, unstar, update, version, view, whoami Specify configs in the ini-formatted file: {USERCONFIG} diff --git a/test/lib/commands/help-search.js b/test/lib/commands/help-search.js index d7f85355a7191..c7f5c444ecb8c 100644 --- a/test/lib/commands/help-search.js +++ b/test/lib/commands/help-search.js @@ -7,7 +7,7 @@ const docsFixtures = { }, dir2: { 'npm-something.md': 'another\ncommand you run\nthat\nreferences exec\nand has multiple lines\nwith no matches\nthat will be ignored\nand another line\nthat does have exec as well', - 'npm-run-script.md': 'the scripted run-script command runs scripts\nand has lines\nsome of which dont match the string run\nor script\nscript', + 'npm-run.md': 'the scripted run command runs scripts\nand has lines\nsome of which dont match the string run\nor script\nscript', 'npm-install.md': 'does a thing in a script\nif a thing does not exist in a thing you run\nto install it and run it maybe in a script', }, dir3: { diff --git a/test/lib/commands/run-script.js b/test/lib/commands/run.js similarity index 99% rename from test/lib/commands/run-script.js rename to test/lib/commands/run.js index 1dd2b5f7d1336..2fd58b356dc40 100644 --- a/test/lib/commands/run-script.js +++ b/test/lib/commands/run.js @@ -12,7 +12,7 @@ const mockRs = async (t, { windows = false, runScript, ...opts } = {}) => { const mock = await mockNpm(t, { ...opts, - command: 'run-script', + command: 'run', mocks: { '@npmcli/run-script': Object.assign( async rs => { @@ -30,7 +30,7 @@ const mockRs = async (t, { windows = false, runScript, ...opts } = {}) => { return { ...mock, RUN_SCRIPTS: () => RUN_SCRIPTS, - runScript: mock['run-script'], + runScript: mock.run, cleanLogs: () => mock.logs.error.map(cleanCwd).join('\n'), } } diff --git a/test/lib/lifecycle-cmd.js b/test/lib/lifecycle-cmd.js index c2701931cac6e..010746d02f283 100644 --- a/test/lib/lifecycle-cmd.js +++ b/test/lib/lifecycle-cmd.js @@ -6,7 +6,7 @@ t.test('create a lifecycle command', async t => { let runArgs = null const { npm } = await mockNpm(t) npm.exec = async (cmd, args) => { - if (cmd === 'run-script') { + if (cmd === 'run') { runArgs = args return 'called the right thing' } diff --git a/test/lib/npm.js b/test/lib/npm.js index 739aa28eb0343..1c4033b083e64 100644 --- a/test/lib/npm.js +++ b/test/lib/npm.js @@ -214,9 +214,9 @@ t.test('npm.load', async t => { }, }) - await npm.exec('run', []) + await npm.exec('run-script', []) - t.equal(npm.command, 'run-script', 'npm.command set to canonical name') + t.equal(npm.command, 'run', 'npm.command set to canonical name') t.matchSnapshot(joinedOutput(), 'should exec workspaces version of commands') }) diff --git a/workspaces/arborist/test/fixtures/reify-cases/tap-with-yarn-lock.js b/workspaces/arborist/test/fixtures/reify-cases/tap-with-yarn-lock.js index 8063de96d5f16..25f15a7aa6640 100644 --- a/workspaces/arborist/test/fixtures/reify-cases/tap-with-yarn-lock.js +++ b/workspaces/arborist/test/fixtures/reify-cases/tap-with-yarn-lock.js @@ -5773,7 +5773,7 @@ module.exports = t => { } ], "scripts": { - "test": "npm run-script lint && npm run-script unit-test", + "test": "npm run lint && npm run unit-test", "lint": "jshint lib/*.js", "unit-test": "mocha --compilers coffee:coffee-script -R spec", "generate-regex": "node tools/generate-identifier-regex.js" diff --git a/workspaces/config/lib/definitions/definitions.js b/workspaces/config/lib/definitions/definitions.js index 360161644c956..6099fc5fbf128 100644 --- a/workspaces/config/lib/definitions/definitions.js +++ b/workspaces/config/lib/definitions/definitions.js @@ -847,7 +847,7 @@ const definitions = { type: Boolean, envExport: false, description: ` - If true, npm will not exit with an error code when \`run-script\` is + If true, npm will not exit with an error code when \`run\` is invoked for a script that isn't defined in the \`scripts\` section of \`package.json\`. This option can be used when it's desirable to optionally run a script when it's present and fail if the script fails. @@ -864,7 +864,7 @@ const definitions = { Note that commands explicitly intended to run a particular script, such as \`npm start\`, \`npm stop\`, \`npm restart\`, \`npm test\`, and \`npm - run-script\` will still run their intended script if \`ignore-scripts\` is + run\` will still run their intended script if \`ignore-scripts\` is set, but they will *not* run any pre- or post-scripts. `, flatten,