1const log = require('./utils/log-shim.js') 2 3// This is the base for all commands whose execWorkspaces just gets 4// a list of workspace names and passes it on to new Arborist() to 5// be able to run a filtered Arborist.reify() at some point. 6 7const BaseCommand = require('./base-command.js') 8class ArboristCmd extends BaseCommand { 9 get isArboristCmd () { 10 return true 11 } 12 13 static params = [ 14 'workspace', 15 'workspaces', 16 'include-workspace-root', 17 'install-links', 18 ] 19 20 static workspaces = true 21 static ignoreImplicitWorkspace = false 22 23 constructor (npm) { 24 super(npm) 25 26 const { config } = this.npm 27 28 // when location isn't set and global isn't true check for a package.json at 29 // the localPrefix and set the location to project if found 30 const locationProject = config.get('location') === 'project' || ( 31 config.isDefault('location') 32 // this is different then `npm.global` which falls back to checking 33 // location which we do not want to use here 34 && !config.get('global') 35 && npm.localPackage 36 ) 37 38 // if audit is not set and we are in global mode and location is not project 39 // and we assume its not a project related context, then we set audit=false 40 if (config.isDefault('audit') && (this.npm.global || !locationProject)) { 41 config.set('audit', false) 42 } else if (this.npm.global && config.get('audit')) { 43 log.warn('config', 'includes both --global and --audit, which is currently unsupported.') 44 } 45 } 46 47 async execWorkspaces (args) { 48 await this.setWorkspaces() 49 return this.exec(args) 50 } 51} 52 53module.exports = ArboristCmd 54