diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2019-10-13 13:16:17 +0200 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2019-10-13 13:16:17 +0200 |
commit | 4eaea26c3dddba80ef6d783fccc9ca35e6fcf153 (patch) | |
tree | 5a65f3df45f24e57a7f0ad6a80b58222598afeda /npmPackages | |
parent | 72482943b0de51f3fec852476a4329ec86314517 (diff) | |
download | npm.nix-4eaea26c3dddba80ef6d783fccc9ca35e6fcf153.tar.gz |
Allow drop some dev. dependencies
Diffstat (limited to 'npmPackages')
-rw-r--r-- | npmPackages/_scripts/drop-dev-deps.js | 25 | ||||
-rw-r--r-- | npmPackages/buildNpmPackage.nix | 7 |
2 files changed, 32 insertions, 0 deletions
diff --git a/npmPackages/_scripts/drop-dev-deps.js b/npmPackages/_scripts/drop-dev-deps.js new file mode 100644 index 0000000..bc8c2f6 --- /dev/null +++ b/npmPackages/_scripts/drop-dev-deps.js @@ -0,0 +1,25 @@ +const process = require('process'); + +const { + pipeThrough +} = require('./package.js'); + +pipeThrough((pkg, done) => { + var notFound = []; + pkg.devDependencies = pkg.devDependencies || {}; + + process.argv.slice(2).forEach((d) => { + if (pkg.devDependencies[d]) { + delete pkg.devDependencies[d]; + } else { + notFound.push(d); + } + }); + + if (notFound.length > 0) { + console.error(`** ERROR: these dev. dependencies are not declared: ${notFound}`); + process.exit(1); + } + + done(pkg); +}); diff --git a/npmPackages/buildNpmPackage.nix b/npmPackages/buildNpmPackage.nix index 5a0f4e5..76f08ee 100644 --- a/npmPackages/buildNpmPackage.nix +++ b/npmPackages/buildNpmPackage.nix @@ -4,6 +4,7 @@ , version , src , npmInputs ? [] # NPM packages used to resolve dependencies +, dropDevDependencies ? [] , buildInputs ? [] # Other build inputs , nativeBuildInputs ? [] , patches ? [] @@ -50,6 +51,12 @@ stdenv.mkDerivation { update-notifier = false NPMRC + ${lib.optionalString (dropDevDependencies != []) '' + node ${scripts}/drop-dev-deps.js ${lib.concatMapStringsSep " " (f: "'${f}'") dropDevDependencies} \ + < package.json > package.json.devdeps + mv package.json.devdeps package.json + ''} + node ${scripts}/resolve.js \ ${lib.optionalString jailbreak "--jailbreak"} \ ${toString npmInputs} < package.json > package.json.resolved |