-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(init): reify on init new workspace
Adds a minimalistic reify step that updates the installed tree after initializing a new workspace. Moved the shared update logic from `lib/commands/version.js` to a `lib/workspaces/update-workspaces.js` module that is reused between both `npm version` and `npm init`. Relates to: npm/rfcs#556 Relates to: npm#4588
- Loading branch information
Showing
8 changed files
with
180 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters