11cb0ef41Sopenharmony_ciconst log = require('./utils/log-shim.js')
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci// This is the base for all commands whose execWorkspaces just gets
41cb0ef41Sopenharmony_ci// a list of workspace names and passes it on to new Arborist() to
51cb0ef41Sopenharmony_ci// be able to run a filtered Arborist.reify() at some point.
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst BaseCommand = require('./base-command.js')
81cb0ef41Sopenharmony_ciclass ArboristCmd extends BaseCommand {
91cb0ef41Sopenharmony_ci  get isArboristCmd () {
101cb0ef41Sopenharmony_ci    return true
111cb0ef41Sopenharmony_ci  }
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ci  static params = [
141cb0ef41Sopenharmony_ci    'workspace',
151cb0ef41Sopenharmony_ci    'workspaces',
161cb0ef41Sopenharmony_ci    'include-workspace-root',
171cb0ef41Sopenharmony_ci    'install-links',
181cb0ef41Sopenharmony_ci  ]
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ci  static workspaces = true
211cb0ef41Sopenharmony_ci  static ignoreImplicitWorkspace = false
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ci  constructor (npm) {
241cb0ef41Sopenharmony_ci    super(npm)
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ci    const { config } = this.npm
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci    // when location isn't set and global isn't true check for a package.json at
291cb0ef41Sopenharmony_ci    // the localPrefix and set the location to project if found
301cb0ef41Sopenharmony_ci    const locationProject = config.get('location') === 'project' || (
311cb0ef41Sopenharmony_ci      config.isDefault('location')
321cb0ef41Sopenharmony_ci      // this is different then `npm.global` which falls back to checking
331cb0ef41Sopenharmony_ci      // location which we do not want to use here
341cb0ef41Sopenharmony_ci      && !config.get('global')
351cb0ef41Sopenharmony_ci      && npm.localPackage
361cb0ef41Sopenharmony_ci    )
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_ci    // if audit is not set and we are in global mode and location is not project
391cb0ef41Sopenharmony_ci    // and we assume its not a project related context, then we set audit=false
401cb0ef41Sopenharmony_ci    if (config.isDefault('audit') && (this.npm.global || !locationProject)) {
411cb0ef41Sopenharmony_ci      config.set('audit', false)
421cb0ef41Sopenharmony_ci    } else if (this.npm.global && config.get('audit')) {
431cb0ef41Sopenharmony_ci      log.warn('config', 'includes both --global and --audit, which is currently unsupported.')
441cb0ef41Sopenharmony_ci    }
451cb0ef41Sopenharmony_ci  }
461cb0ef41Sopenharmony_ci
471cb0ef41Sopenharmony_ci  async execWorkspaces (args) {
481cb0ef41Sopenharmony_ci    await this.setWorkspaces()
491cb0ef41Sopenharmony_ci    return this.exec(args)
501cb0ef41Sopenharmony_ci  }
511cb0ef41Sopenharmony_ci}
521cb0ef41Sopenharmony_ci
531cb0ef41Sopenharmony_cimodule.exports = ArboristCmd
54