NET-Web-API-w-Angular/my-app/node_modules/@npmcli/package-json/lib/update-workspaces.js

27 lines
626 B
JavaScript
Raw Normal View History

2024-02-09 00:38:41 +00:00
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