/snap/node/11782/lib/node_modules/npm/lib/utils
NameSizeModeActions
audit-error.js10450644editdlrm
auth.js32910644editdlrm
cmd-list.js29590644editdlrm
completion.fish15960644editdlrm
completion.sh18980755editdlrm
did-you-mean.js11880644editdlrm
display.js157490644editdlrm
error-message.js151500644editdlrm
explain-dep.js36480644editdlrm
explain-eresolve.js26170644editdlrm
format-bytes.js6290644editdlrm
format-search-stream.js48080644editdlrm
format.js19570644editdlrm
get-identity.js8020644editdlrm
get-workspaces.js17480644editdlrm
installed-deep.js11290644editdlrm
installed-shallow.js5830644editdlrm
is-windows.js1770644editdlrm
log-file.js79710644editdlrm
npm-usage.js20640644editdlrm
open-url.js24140644editdlrm
output-error.js7670644editdlrm
ping.js2620644editdlrm
queryable.js97850644editdlrm
read-user-info.js19560644editdlrm
reify-finish.js8860644editdlrm
reify-output.js57880644editdlrm
sbom-cyclonedx.js53310644editdlrm
sbom-spdx.js46960644editdlrm
tar.js35520644editdlrm
timers.js21200644editdlrm
update-workspaces.js10130644editdlrm
validate-lockfile.js10230644editdlrm
verify-signatures.js122260644editdlrm
Edit: /snap/node/11782/lib/node_modules/npm/lib/utils/get-workspaces.js (1748B)
const { resolve, relative } = require('node:path') const mapWorkspaces = require('@npmcli/map-workspaces') const { minimatch } = require('minimatch') const pkgJson = require('@npmcli/package-json') // minimatch wants forward slashes only for glob patterns const globify = pattern => pattern.split('\\').join('/') // Returns an Map of paths to workspaces indexed by workspace name // { foo => '/path/to/foo' } const getWorkspaces = async (filters, { path, includeWorkspaceRoot, relativeFrom }) => { // TODO we need a better error to be bubbled up here if this call fails const { content: pkg } = await pkgJson.normalize(path) const workspaces = await mapWorkspaces({ cwd: path, pkg }) let res = new Map() if (includeWorkspaceRoot) { res.set(pkg.name, path) } if (!filters.length) { res = new Map([...res, ...workspaces]) } for (const filterArg of filters) { for (const [workspaceName, workspacePath] of workspaces.entries()) { let relativePath = relative(relativeFrom, workspacePath) if (filterArg.startsWith('./')) { relativePath = `./${relativePath}` } const relativeFilter = relative(path, filterArg) if (filterArg === workspaceName || resolve(relativeFrom, filterArg) === workspacePath || minimatch(relativePath, `${globify(relativeFilter)}/*`) || minimatch(relativePath, `${globify(filterArg)}/*`) ) { res.set(workspaceName, workspacePath) } } } if (!res.size) { let msg = '!' if (filters.length) { msg = `:\n ${filters.reduce( (acc, filterArg) => `${acc} --workspace=${filterArg}`, '')}` } throw new Error(`No workspaces found${msg}`) } return res } module.exports = getWorkspaces