• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict'
2
3const reifyFinish = require('../utils/reify-finish.js')
4
5async function updateWorkspaces ({
6  config,
7  flatOptions,
8  localPrefix,
9  npm,
10  workspaces,
11}) {
12  if (!flatOptions.workspacesUpdate || !workspaces.length) {
13    return
14  }
15
16  // default behavior is to not save by default in order to avoid
17  // race condition problems when publishing multiple workspaces
18  // that have dependencies on one another, it might still be useful
19  // in some cases, which then need to set --save
20  const save = config.isDefault('save')
21    ? false
22    : config.get('save')
23
24  // runs a minimalistic reify update, targeting only the workspaces
25  // that had version updates and skipping fund/audit/save
26  const opts = {
27    ...flatOptions,
28    audit: false,
29    fund: false,
30    path: localPrefix,
31    save,
32  }
33  const Arborist = require('@npmcli/arborist')
34  const arb = new Arborist(opts)
35
36  await arb.reify({ ...opts, update: workspaces })
37  await reifyFinish(npm, arb)
38}
39
40module.exports = updateWorkspaces
41