update-workspaces.js 997 B

12345678910111213141516171819202122232425262728293031323334353637
  1. 'use strict'
  2. const reifyFinish = require('../utils/reify-finish.js')
  3. async function updateWorkspaces ({
  4. config,
  5. flatOptions,
  6. localPrefix,
  7. npm,
  8. workspaces,
  9. }) {
  10. if (!flatOptions.workspacesUpdate || !workspaces.length) {
  11. return
  12. }
  13. // 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
  14. // it might still be useful in some cases, which then need to set --save
  15. const save = config.isDefault('save')
  16. ? false
  17. : config.get('save')
  18. // runs a minimalistic reify update, targeting only the workspaces that had version updates and skipping fund/audit/save
  19. const opts = {
  20. ...flatOptions,
  21. audit: false,
  22. fund: false,
  23. path: localPrefix,
  24. save,
  25. }
  26. const Arborist = require('@npmcli/arborist')
  27. const arb = new Arborist(opts)
  28. await arb.reify({ ...opts, update: workspaces })
  29. await reifyFinish(npm, arb)
  30. }
  31. module.exports = updateWorkspaces