From 8ffeb71dfb248b4a76744bd06cd4d6100f17c8ae Mon Sep 17 00:00:00 2001 From: Gar Date: Thu, 7 Oct 2021 18:40:03 -0700 Subject: chore: refactor commands This is the first phase of refactoring the internal structure of the npm commands to set us up for future changes. This iteration changes the function signature of `exec` for all the commands to be a async (no more callbacks), and also groups all the commands into their own subdirectory. It also removes the Proxy `npm.commands` object, in favor of an `npm.cmd` and `npm.exec` function that breaks up the two things that proxy was doing. Namely, getting to the attributes of a given command (`npm.cmd` now does this), and actually running the command `npm.exec` does this. PR-URL: https://github.com/npm/cli/pull/3959 Credit: @wraithgar Close: #3959 Reviewed-by: @lukekarrys --- lib/workspaces/arborist-cmd.js | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 lib/workspaces/arborist-cmd.js (limited to 'lib/workspaces') diff --git a/lib/workspaces/arborist-cmd.js b/lib/workspaces/arborist-cmd.js deleted file mode 100644 index a75b351be..000000000 --- a/lib/workspaces/arborist-cmd.js +++ /dev/null @@ -1,29 +0,0 @@ -// This is the base for all commands whose execWorkspaces just gets -// a list of workspace names and passes it on to new Arborist() to -// be able to run a filtered Arborist.reify() at some point. - -const BaseCommand = require('../base-command.js') -class ArboristCmd extends BaseCommand { - get isArboristCmd () { - return true - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'workspace', - 'workspaces', - 'include-workspace-root', - ] - } - - execWorkspaces (args, filters, cb) { - this.setWorkspaces(filters, true) - .then(() => { - this.exec(args, cb) - }) - .catch(er => cb(er)) - } -} - -module.exports = ArboristCmd -- cgit v1.2.3