update
This commit is contained in:
26
package/node_modules/@npmcli/package-json/lib/update-workspaces.js
generated
vendored
Normal file
26
package/node_modules/@npmcli/package-json/lib/update-workspaces.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
const updateWorkspaces = ({ content, originalContent = {} }) => {
|
||||
const newWorkspaces = content.workspaces
|
||||
|
||||
if (!newWorkspaces) {
|
||||
return originalContent
|
||||
}
|
||||
|
||||
// validate workspaces content being appended
|
||||
const hasInvalidWorkspaces = () =>
|
||||
newWorkspaces.some(w => !(typeof w === 'string'))
|
||||
if (!newWorkspaces.length || hasInvalidWorkspaces()) {
|
||||
throw Object.assign(
|
||||
new TypeError('workspaces should be an array of strings.'),
|
||||
{ code: 'EWORKSPACESINVALID' }
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
...originalContent,
|
||||
workspaces: [
|
||||
...newWorkspaces,
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = updateWorkspaces
|
Reference in New Issue
Block a user