Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
byp
/
izo
/
con7ext_sym404
/
rintoar.txt
/
usr
/
lib
/
node_modules
/
npm
/
node_modules
/
@npmcli
/
package-json
/
lib
:
update-workspaces.js
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
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