PHP 8.2.30
Preview: update-workspaces.js Size: 626 B
/opt/alt/alt-nodejs24/root/lib/node_modules/npm/node_modules/@npmcli/package-json/lib/update-workspaces.js

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

Directory Contents

Dirs: 0 × Files: 8

Name Size Perms Modified Actions
6.74 KB lrw-r--r-- 2026-02-23 07:38:42
Edit Download
7.57 KB lrw-r--r-- 2026-02-23 07:38:42
Edit Download
19.83 KB lrw-r--r-- 2026-02-23 07:38:42
Edit Download
1.02 KB lrw-r--r-- 2026-02-23 07:38:42
Edit Download
3.50 KB lrw-r--r-- 2026-02-23 07:38:42
Edit Download
1.98 KB lrw-r--r-- 2026-02-23 07:38:42
Edit Download
664 B lrw-r--r-- 2026-02-23 07:38:42
Edit Download
626 B lrw-r--r-- 2026-02-23 07:38:42
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).