mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-06 22:18:17 -05:00
5
.changeset/eighty-hotels-draw.md
Normal file
5
.changeset/eighty-hotels-draw.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-script-runners": patch
|
||||
---
|
||||
|
||||
--no-bail should work with non-recursive run commands as well.
|
||||
@@ -92,6 +92,10 @@ For options that may be used with `-r`, see "pnpm help recursive"',
|
||||
name: '--recursive',
|
||||
shortAlias: '-r',
|
||||
},
|
||||
{
|
||||
description: 'The command will exit with a 0 exit code even if the script fails',
|
||||
name: '--no-bail',
|
||||
},
|
||||
IF_PRESENT_OPTION_HELP,
|
||||
PARALLEL_OPTION_HELP,
|
||||
...UNIVERSAL_OPTIONS,
|
||||
@@ -166,12 +170,18 @@ so you may run "pnpm -w ${scriptName}"`,
|
||||
if (pnpPath) {
|
||||
lifecycleOpts.extraEnv = makeNodeRequireOption(pnpPath)
|
||||
}
|
||||
if (manifest.scripts?.[`pre${scriptName}`]) {
|
||||
await runLifecycleHooks(`pre${scriptName}`, manifest, lifecycleOpts)
|
||||
}
|
||||
await runLifecycleHooks(scriptName, manifest, { ...lifecycleOpts, args: passedThruArgs })
|
||||
if (manifest.scripts?.[`post${scriptName}`]) {
|
||||
await runLifecycleHooks(`post${scriptName}`, manifest, lifecycleOpts)
|
||||
try {
|
||||
if (manifest.scripts?.[`pre${scriptName}`]) {
|
||||
await runLifecycleHooks(`pre${scriptName}`, manifest, lifecycleOpts)
|
||||
}
|
||||
await runLifecycleHooks(scriptName, manifest, { ...lifecycleOpts, args: passedThruArgs })
|
||||
if (manifest.scripts?.[`post${scriptName}`]) {
|
||||
await runLifecycleHooks(`post${scriptName}`, manifest, lifecycleOpts)
|
||||
}
|
||||
} catch (err) {
|
||||
if (opts.bail !== false) {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
@@ -44,6 +44,26 @@ test('pnpm run: returns correct exit code', async () => {
|
||||
expect(err.errno).toBe(1)
|
||||
})
|
||||
|
||||
test('pnpm run --no-bail never fails', async () => {
|
||||
prepare({
|
||||
scripts: {
|
||||
exit1: 'node recordArgs && exit 1',
|
||||
},
|
||||
})
|
||||
await fs.writeFile('args.json', '[]', 'utf8')
|
||||
await fs.writeFile('recordArgs.js', RECORD_ARGS_FILE, 'utf8')
|
||||
|
||||
await run.handler({
|
||||
bail: false,
|
||||
dir: process.cwd(),
|
||||
extraBinPaths: [],
|
||||
rawConfig: {},
|
||||
}, ['exit1'])
|
||||
|
||||
const { default: args } = await import(path.resolve('args.json'))
|
||||
expect(args).toStrictEqual([[]])
|
||||
})
|
||||
|
||||
const RECORD_ARGS_FILE = 'require(\'fs\').writeFileSync(\'args.json\', JSON.stringify(require(\'./args.json\').concat([process.argv.slice(2)])), \'utf8\')'
|
||||
|
||||
test('run: pass the args to the command that is specfied in the build script', async () => {
|
||||
|
||||
Reference in New Issue
Block a user