1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
|
|