diff options
author | claudiahdz <cghr1990@gmail.com> | 2020-06-05 01:21:33 +0300 |
---|---|---|
committer | claudiahdz <cghr1990@gmail.com> | 2020-06-06 01:20:15 +0300 |
commit | 56d458ebc47dc0e5b3e3b699ac7e939f00e0be50 (patch) | |
tree | df7ace9dbbb569e60b151f8c5aa9196d0e8d6cd2 /lib/prune.js | |
parent | 05e76efe4d4ce6f3ee218a3f501c356036aae57a (diff) |
feat: use Arborist for dedupe and prune
Diffstat (limited to 'lib/prune.js')
-rw-r--r-- | lib/prune.js | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/prune.js b/lib/prune.js index 6e1cd9318..e675df30d 100644 --- a/lib/prune.js +++ b/lib/prune.js @@ -1,20 +1,25 @@ -// prune extraneous packages. -const util = require('util') +// prune extraneous packages +const npm = require('./npm.js') const Arborist = require('@npmcli/arborist') -const rimraf = util.promisify(require('rimraf')) -const reifyOutput = require('./utils/reify-output.js') const usageUtil = require('./utils/usage.js') -const usage = usageUtil('prune', - 'npm prune [[<@scope>/]<pkg>...] [--production]') +const reifyOutput = require('./utils/reify-output.js') -const completion = require('./utils/completion/installed-deep.js') +const usage = usageUtil('prune', + 'npm prune [[<@scope>/]<pkg>...] [--production]' +) +const completion = (cb) => cb(null, []) -const cmd = (args, cb) => prune(args).then(() => cb()).catch(cb) +const cmd = (args, cb) => prune().then(() => cb()).catch(cb) -const prune = async args => { - require('npmlog').warn('coming soon!') - throw new Error('not yet implemented') +const prune = async () => { + const where = npm.prefix + const arb = new Arborist({ + ...npm.flatOptions, + path: where + }) + await arb.prune() + reifyOutput(arb) } module.exports = Object.assign(cmd, { usage, completion }) |