feat: skip scripts that use "npx only-allow pnpm"

ref #2517
PR #2518
This commit is contained in:
Zoltan Kochan
2020-05-02 12:24:41 +03:00
committed by Zoltan Kochan
parent c80d4ba3c3
commit 2ec4c4eb9a
3 changed files with 9 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/lifecycle": minor
---
Don't execute lifecycle scripts that are meant to prevent the usage of npm or Yarn.

View File

@@ -1,5 +1,6 @@
{
"scripts": {
"preinstall": "npx only-allow pnpm",
"lint": "tslint --config tslint.json **/src/**/*.ts **/test/**/*.ts --exclude '**/node_modules/**'",
"test-master": "pnpm run lint && pnpm run compile && run-p -r verdaccio test-pkgs-master",
"test-pkgs-master": "cross-env PNPM_REGISTRY_MOCK_UPLINK=http://localhost:7348 pnpm run _test --no-sort --filter=./packages --filter=./privatePackages",

View File

@@ -32,6 +32,9 @@ export default async function runLifecycleHook (
if (opts.args?.length && m.scripts?.[stage]) {
m.scripts[stage] = `${m.scripts[stage]} ${opts.args.map((arg) => `"${arg}"`).join(' ')}`
}
// This script is used to prevent the usage of npm or Yarn.
// It does nothing, when pnpm is used, so we may skip its execution.
if (m.scripts[stage] === 'npx only-allow pnpm') return
if (opts.stdio !== 'inherit') {
lifecycleLogger.debug({
depPath: opts.depPath,