Skip to content

Commit 0318f44

Browse files
wraithgarlukekarrys
authored andcommitted
fix: remove implicit if-present logic from run-script workspaces
BREAKING CHANGE: npm no longer treats missing scripts as a special case in workspace mode. Use `if-present` to ignore missing scripts.
1 parent 392682b commit 0318f44

File tree

2 files changed

+2
-21
lines changed

2 files changed

+2
-21
lines changed

lib/commands/run-script.js

+1-15
Original file line numberDiff line numberDiff line change
@@ -207,24 +207,10 @@ class RunScript extends BaseCommand {
207207
log.error(err)
208208
log.error(` in workspace: ${pkg._id || pkg.name}`)
209209
log.error(` at location: ${workspacePath}`)
210-
211-
const scriptMissing = err.message.startsWith('Missing script')
212-
213-
// avoids exiting with error code in case there's scripts missing
214-
// in some workspaces since other scripts might have succeeded
215-
if (!scriptMissing) {
216-
process.exitCode = 1
217-
}
218-
219-
return scriptMissing
210+
process.exitCode = 1
220211
})
221212
res.push(runResult)
222213
}
223-
224-
// in case **all** tests are missing, then it should exit with error code
225-
if (res.every(Boolean)) {
226-
throw new Error(`Missing script: ${args[0]}`)
227-
}
228214
}
229215

230216
async listWorkspaces (args, filters) {

test/lib/commands/run-script.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -781,12 +781,7 @@ t.test('workspaces', async t => {
781781
t.test('missing scripts in all workspaces', async t => {
782782
const { runScript, RUN_SCRIPTS, cleanLogs } = await mockWorkspaces(t, { exec: null })
783783

784-
await t.rejects(
785-
runScript.exec(['missing-script']),
786-
/Missing script: missing-script/,
787-
'should throw missing script error'
788-
)
789-
784+
await runScript.exec(['missing-script'])
790785
t.match(RUN_SCRIPTS(), [])
791786
t.strictSame(
792787
cleanLogs(),

0 commit comments

Comments
 (0)