summaryrefslogtreecommitdiff
path: root/deps/npm/lib/workspaces/update-workspaces.js
blob: 892f366e9980a262b8890c369b1ffd748a3528e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict'

const reifyFinish = require('../utils/reify-finish.js')

async function updateWorkspaces ({
  config,
  flatOptions,
  localPrefix,
  npm,
  workspaces,
}) {
  if (!flatOptions.workspacesUpdate || !workspaces.length) {
    return
  }

  // default behavior is to not save by default in order to avoid
  // race condition problems when publishing multiple workspaces
  // that have dependencies on one another, it might still be useful
  // in some cases, which then need to set --save
  const save = config.isDefault('save')
    ? false
    : config.get('save')

  // runs a minimalistic reify update, targeting only the workspaces
  // that had version updates and skipping fund/audit/save
  const opts = {
    ...flatOptions,
    audit: false,
    fund: false,
    path: localPrefix,
    save,
  }
  const Arborist = require('@npmcli/arborist')
  const arb = new Arborist(opts)

  await arb.reify({ ...opts, update: workspaces })
  await reifyFinish(npm, arb)
}

module.exports = updateWorkspaces