fix: ignoreScripts shoud be true when lockfileOnly is true (#3765)

closes: #3750

Co-authored-by: Zoltan Kochan <z@kochan.io>
This commit is contained in:
zoomdong
2021-09-14 08:17:35 +08:00
committed by GitHub
parent 12686104e6
commit 141d2f02e9
3 changed files with 14 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
"supi": patch
---
Scripts should always be ignored when only the lockfile is being updated.

View File

@@ -4,5 +4,8 @@
"dependencies": {
"dep-of-pkg-with-1-dep": "^101.0.0",
"pkg-with-1-dep": "*"
},
"scripts": {
"prepare": "exit 1"
}
}

View File

@@ -167,9 +167,12 @@ export default async (
...opts,
storeDir: defaultOpts.storeDir,
}
if (!extendedOpts.useLockfile && extendedOpts.lockfileOnly) {
throw new PnpmError('CONFIG_CONFLICT_LOCKFILE_ONLY_WITH_NO_LOCKFILE',
`Cannot generate a ${WANTED_LOCKFILE} because lockfile is set to false`)
if (extendedOpts.lockfileOnly) {
extendedOpts.ignoreScripts = true
if (!extendedOpts.useLockfile) {
throw new PnpmError('CONFIG_CONFLICT_LOCKFILE_ONLY_WITH_NO_LOCKFILE',
`Cannot generate a ${WANTED_LOCKFILE} because lockfile is set to false`)
}
}
if (extendedOpts.userAgent.startsWith('npm/')) {
extendedOpts.userAgent = `${extendedOpts.packageManager.name}/${extendedOpts.packageManager.version} ${extendedOpts.userAgent}`