diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2019-10-12 21:31:28 +0200 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2019-10-12 21:31:28 +0200 |
commit | 2d7643789f7fc2abcb3bc9c12e5e0ad91ed90fdb (patch) | |
tree | 97ec94aaa8e2a2a37389f879e7b9e57963ae0dd0 /npmPackages/_scripts | |
parent | 895f1f156d214a850d8a9b994e6a54589b2e20c7 (diff) | |
download | npm.nix-2d7643789f7fc2abcb3bc9c12e5e0ad91ed90fdb.tar.gz |
Refactor stripping
Motivation: remove unsed scripts like prepublish
Diffstat (limited to 'npmPackages/_scripts')
-rw-r--r-- | npmPackages/_scripts/strip.js | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/npmPackages/_scripts/strip.js b/npmPackages/_scripts/strip.js index e76bf6d..526730d 100644 --- a/npmPackages/_scripts/strip.js +++ b/npmPackages/_scripts/strip.js @@ -5,14 +5,20 @@ const { } = require('./package.js'); -var stripDependencies = false; +var phase; const args = process.argv.slice(2); for (var i = 0; i < args.length; i++) { switch (args[i]) { - case '--strip-dependencies': - stripDependencies = true; + case '--post-configure': + phase = 'postConfigure'; + break; + case '--pre-install': + phase = 'preInstall'; + break; + case '--post-install': + phase = 'postInstall'; break; default: ; @@ -20,18 +26,30 @@ for (var i = 0; i < args.length; i++) { } pipeThrough((pkg, done) => { - delete pkg.devDependencies; - delete pkg.engines; - delete pkg.keywords; - delete pkg.optionalDependencies; - delete pkg.peerDependencies; - delete pkg.scripts; - delete pkg.tap; - delete pkg.xo; - - if (stripDependencies) { - delete pkg.dependencies; + switch (phase) { + case 'postInstall': + delete pkg.dependencies; + // fall throw + + case 'preInstall': + delete pkg.engines; + delete pkg.keywords; + delete pkg.scripts; + delete pkg.tap; + delete pkg.xo; + // fall throw + + case 'postConfigure': + delete pkg.devDependencies; + delete pkg.optionalDependencies; + delete pkg.peerDependencies; + if (pkg.scripts) { + delete pkg.scripts.prepublish; + } + break; + default: + throw (`Unknown phase: "${phase}"`); } done(pkg); -}); +});
\ No newline at end of file |