Skip to content

Commit 57aa89f

Browse files
authored
feat: use run by default and run-script as the alias (#8265)
npm/statusboard#467 This pull request standardizes the use of `npm run` across the codebase and documentation, replacing all references to the `npm run-script` - now an alias. It also includes file renaming and updates to reflect this change.
1 parent 78b5a6f commit 57aa89f

File tree

34 files changed

+397
-132
lines changed

34 files changed

+397
-132
lines changed

docs/lib/content/commands/npm-exec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ project.
274274

275275
### See Also
276276

277-
* [npm run-script](/commands/npm-run-script)
277+
* [npm run](/commands/npm-run)
278278
* [npm scripts](/using-npm/scripts)
279279
* [npm test](/commands/npm-test)
280280
* [npm start](/commands/npm-start)

docs/lib/content/commands/npm-restart.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ description: Restart a package
1010

1111
### Description
1212

13-
This restarts a project. It is equivalent to running `npm run-script
13+
This restarts a project. It is equivalent to running `npm run
1414
restart`.
1515

1616
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
3838

3939
### See Also
4040

41-
* [npm run-script](/commands/npm-run-script)
41+
* [npm run](/commands/npm-run)
4242
* [npm scripts](/using-npm/scripts)
4343
* [npm test](/commands/npm-test)
4444
* [npm start](/commands/npm-start)

docs/lib/content/commands/npm-run-script.md renamed to docs/lib/content/commands/npm-run.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: npm-run-script
2+
title: npm-run
33
section: 1
44
description: Run arbitrary package scripts
55
---

docs/lib/content/commands/npm-shrinkwrap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ design and purpose of package locks in npm, see
2020
### See Also
2121

2222
* [npm install](/commands/npm-install)
23-
* [npm run-script](/commands/npm-run-script)
23+
* [npm run](/commands/npm-run)
2424
* [npm scripts](/using-npm/scripts)
2525
* [package.json](/configuring-npm/package-json)
2626
* [package-lock.json](/configuring-npm/package-lock-json)

docs/lib/content/commands/npm-start.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ the file specified in a package's `"main"` attribute when evoking with
2121
`node .`
2222

2323
As of [`npm@2.0.0`](https://blog.npmjs.org/post/98131109725/npm-2-0-0), you can
24-
use custom arguments when executing scripts. Refer to [`npm run-script`](/commands/npm-run-script) for more details.
24+
use custom arguments when executing scripts. Refer to [`npm run`](/commands/npm-run) for more details.
2525

2626
### Example
2727

@@ -49,7 +49,7 @@ npm start
4949

5050
### See Also
5151

52-
* [npm run-script](/commands/npm-run-script)
52+
* [npm run](/commands/npm-run)
5353
* [npm scripts](/using-npm/scripts)
5454
* [npm test](/commands/npm-test)
5555
* [npm restart](/commands/npm-restart)

docs/lib/content/commands/npm-stop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ npm stop
4242

4343
### See Also
4444

45-
* [npm run-script](/commands/npm-run-script)
45+
* [npm run](/commands/npm-run)
4646
* [npm scripts](/using-npm/scripts)
4747
* [npm test](/commands/npm-test)
4848
* [npm start](/commands/npm-start)

docs/lib/content/commands/npm-test.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ npm test
3737

3838
### See Also
3939

40-
* [npm run-script](/commands/npm-run-script)
40+
* [npm run](/commands/npm-run)
4141
* [npm scripts](/using-npm/scripts)
4242
* [npm start](/commands/npm-start)
4343
* [npm restart](/commands/npm-restart)

docs/lib/content/commands/npm-version.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ deletes the `build/temp` directory.
9898
### See Also
9999

100100
* [npm init](/commands/npm-init)
101-
* [npm run-script](/commands/npm-run-script)
101+
* [npm run](/commands/npm-run)
102102
* [npm scripts](/using-npm/scripts)
103103
* [package.json](/configuring-npm/package-json)
104104
* [config](/using-npm/config)

docs/lib/content/commands/npx.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ This resulted in some shifts in its functionality:
153153

154154
### See Also
155155

156-
* [npm run-script](/commands/npm-run-script)
156+
* [npm run](/commands/npm-run)
157157
* [npm scripts](/using-npm/scripts)
158158
* [npm test](/commands/npm-test)
159159
* [npm start](/commands/npm-start)

docs/lib/content/configuring-npm/package-json.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ file in the `bin` field, so it is available to run by `name` or `name.cmd` (on
378378
Windows PowerShell). When this package is installed as a dependency in another
379379
package, the file will be linked where it will be available to that package
380380
either directly by `npm exec` or by name in other scripts when invoking them
381-
via `npm run-script`.
381+
via `npm run`.
382382

383383

384384
For example, myapp could have this:

docs/lib/content/nav.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@
144144
- title: npm root
145145
url: /commands/npm-root
146146
description: Display npm root
147-
- title: npm run-script
148-
url: /commands/npm-run-script
147+
- title: npm run
148+
url: /commands/npm-run
149149
description: Run arbitrary package scripts
150150
- title: npm sbom
151151
url: /commands/npm-sbom

docs/lib/content/using-npm/scripts.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description: How npm handles the "scripts" field
99
The `"scripts"` property of your `package.json` file supports a number
1010
of built-in scripts and their preset life cycle events as well as
1111
arbitrary scripts. These all can be executed by running
12-
`npm run-script <stage>` or `npm run <stage>` for short. *Pre* and *post*
12+
`npm run <stage>` or `npm run <stage>` for short. *Pre* and *post*
1313
commands with matching names will be run for those as well (e.g. `premyscript`,
1414
`myscript`, `postmyscript`). Scripts from dependencies can be run with
1515
`npm explore <pkg> -- npm run <stage>`.
@@ -180,7 +180,7 @@ If there is a `restart` script defined, these events are run, otherwise
180180
* `restart`
181181
* `postrestart`
182182

183-
#### [`npm run <user defined>`](/commands/npm-run-script)
183+
#### [`npm run <user defined>`](/commands/npm-run)
184184

185185
* `pre<user-defined>`
186186
* `<user-defined>`
@@ -358,7 +358,7 @@ file.
358358

359359
### See Also
360360

361-
* [npm run-script](/commands/npm-run-script)
361+
* [npm run](/commands/npm-run)
362362
* [package.json](/configuring-npm/package-json)
363363
* [npm developers](/using-npm/developers)
364364
* [npm install](/commands/npm-install)

docs/lib/content/using-npm/workspaces.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,6 @@ npm run test --workspaces --if-present
221221

222222
* [npm install](/commands/npm-install)
223223
* [npm publish](/commands/npm-publish)
224-
* [npm run-script](/commands/npm-run-script)
224+
* [npm run](/commands/npm-run)
225225
* [config](/using-npm/config)
226226

lib/commands/restart.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const LifecycleCmd = require('../lifecycle-cmd.js')
22

3-
// This ends up calling run-script(['restart', ...args])
3+
// This ends up calling run(['restart', ...args])
44
class Restart extends LifecycleCmd {
55
static description = 'Restart a package'
66
static name = 'restart'

lib/commands/run-script.js renamed to lib/commands/run.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class RunScript extends BaseCommand {
1616
'script-shell',
1717
]
1818

19-
static name = 'run-script'
19+
static name = 'run'
2020
static usage = ['<command> [-- <args>]']
2121
static workspaces = true
2222
static ignoreImplicitWorkspace = false
@@ -201,7 +201,7 @@ class RunScript extends BaseCommand {
201201
}
202202

203203
if (runScripts.length) {
204-
const via = `via \`${blue('npm run-script')}\`:`
204+
const via = `via \`${blue('npm run')}\`:`
205205
if (!cmds.length) {
206206
output.standard(`${title('Scripts')} available ${pkgId} ${via}`)
207207
} else {

lib/commands/start.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const LifecycleCmd = require('../lifecycle-cmd.js')
22

3-
// This ends up calling run-script(['start', ...args])
3+
// This ends up calling run(['start', ...args])
44
class Start extends LifecycleCmd {
55
static description = 'Start a package'
66
static name = 'start'

lib/commands/stop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const LifecycleCmd = require('../lifecycle-cmd.js')
22

3-
// This ends up calling run-script(['stop', ...args])
3+
// This ends up calling run(['stop', ...args])
44
class Stop extends LifecycleCmd {
55
static description = 'Stop a package'
66
static name = 'stop'

lib/commands/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const LifecycleCmd = require('../lifecycle-cmd.js')
22

3-
// This ends up calling run-script(['test', ...args])
3+
// This ends up calling run(['test', ...args])
44
class Test extends LifecycleCmd {
55
static description = 'Test a package'
66
static name = 'test'

lib/lifecycle-cmd.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ class LifecycleCmd extends BaseCommand {
99
static ignoreImplicitWorkspace = false
1010

1111
async exec (args) {
12-
return this.npm.exec('run-script', [this.constructor.name, ...args])
12+
return this.npm.exec('run', [this.constructor.name, ...args])
1313
}
1414

1515
async execWorkspaces (args) {
16-
return this.npm.exec('run-script', [this.constructor.name, ...args])
16+
return this.npm.exec('run', [this.constructor.name, ...args])
1717
}
1818
}
1919

lib/npm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class Npm {
221221
const command = new Command(this)
222222

223223
// since 'test', 'start', 'stop', etc. commands re-enter this function
224-
// to call the run-script command, we need to only set it one time.
224+
// to call the run command, we need to only set it one time.
225225
if (!this.#command) {
226226
this.#command = command
227227
process.env.npm_command = this.command

lib/utils/cmd-list.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const commands = [
5050
'repo',
5151
'restart',
5252
'root',
53-
'run-script',
53+
'run',
5454
'sbom',
5555
'search',
5656
'set',
@@ -105,7 +105,7 @@ const aliases = {
105105
t: 'test',
106106
ddp: 'dedupe',
107107
v: 'view',
108-
run: 'run-script',
108+
'run-script': 'run',
109109
'clean-install': 'ci',
110110
'clean-install-test': 'install-ci-test',
111111
x: 'exec',
@@ -132,9 +132,9 @@ const aliases = {
132132
'dist-tags': 'dist-tag',
133133
upgrade: 'update',
134134
udpate: 'update',
135-
rum: 'run-script',
135+
rum: 'run',
136136
sit: 'install-ci-test',
137-
urn: 'run-script',
137+
urn: 'run',
138138
ogr: 'org',
139139
'add-user': 'adduser',
140140
}

smoke-tests/tap-snapshots/test/index.js.test.cjs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ All commands:
2727
help-search, init, install, install-ci-test, install-test,
2828
link, ll, login, logout, ls, org, outdated, owner, pack,
2929
ping, pkg, prefix, profile, prune, publish, query, rebuild,
30-
repo, restart, root, run-script, sbom, search, set,
31-
shrinkwrap, star, stars, start, stop, team, test, token,
32-
undeprecate, uninstall, unpublish, unstar, update, version,
33-
view, whoami
30+
repo, restart, root, run, sbom, search, set, shrinkwrap,
31+
star, stars, start, stop, team, test, token, undeprecate,
32+
uninstall, unpublish, unstar, update, version, view, whoami
3433
3534
Specify configs in the ini-formatted file:
3635
{NPM}/{TESTDIR}/home/.npmrc
@@ -355,7 +354,7 @@ exports[`test/index.js TAP basic npm prefix > should have expected prefix output
355354
{NPM}/{TESTDIR}/project
356355
`
357356

358-
exports[`test/index.js TAP basic npm run-script > should have expected run-script output 1`] = `
357+
exports[`test/index.js TAP basic npm run > should have expected run output 1`] = `
359358
> project@1.0.0 hello
360359
> echo Hello
361360

smoke-tests/test/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ t.test('basic', async t => {
182182
)
183183
})
184184

185-
await t.test('npm run-script', async t => {
186-
const cmdRes = await npm('run', 'hello')
185+
await t.test('npm run', async t => {
186+
const cmdRes = await npm('run-script', 'hello')
187187

188-
t.matchSnapshot(cmdRes.stdout, 'should have expected run-script output')
188+
t.matchSnapshot(cmdRes.stdout, 'should have expected run output')
189189
})
190190

191191
await t.test('npm prefix', async t => {

tap-snapshots/test/lib/commands/completion.js.test.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Array [
8888
repo
8989
restart
9090
root
91-
run-script
91+
run
9292
sbom
9393
search
9494
set
@@ -135,7 +135,7 @@ Array [
135135
t
136136
ddp
137137
v
138-
run
138+
run-script
139139
clean-install
140140
clean-install-test
141141
x

tap-snapshots/test/lib/commands/publish.js.test.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Object {
197197
"man/man1/npm-repo.1",
198198
"man/man1/npm-restart.1",
199199
"man/man1/npm-root.1",
200-
"man/man1/npm-run-script.1",
200+
"man/man1/npm-run.1",
201201
"man/man1/npm-sbom.1",
202202
"man/man1/npm-search.1",
203203
"man/man1/npm-shrinkwrap.1",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy