node/deps/npm/lib/workspaces/update-workspaces.js
npm CLI robot 47ea59fad1
deps: upgrade npm to 8.12.1
PR-URL: https://github.com/nodejs/node/pull/43301
Reviewed-By: Ruy Adorno <ruyadorno@github.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
2022-06-14 07:04:21 +01:00

41 lines
1012 B
JavaScript

'use strict'
const Arborist = require('@npmcli/arborist')
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, targetting only the workspaces
// that had version updates and skipping fund/audit/save
const opts = {
...flatOptions,
audit: false,
fund: false,
path: localPrefix,
save,
}
const arb = new Arborist(opts)
await arb.reify({ ...opts, update: workspaces })
await reifyFinish(npm, arb)
}
module.exports = updateWorkspaces