package
Retrieves a name:pathname Map for a given workspaces config
npm install @npmcli/map-workspacesGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Retrieves a name:pathname Map for a given workspaces config.
Long version: Reads the workspaces property from a valid workspaces configuration object and traverses the paths and globs defined there in order to find valid nested packages and return a Map of all found packages where keys are package names and values are folder locations.
npm install @npmcli/map-workspaces
const mapWorkspaces = require('@npmcli/map-workspaces')
await mapWorkspaces({
cwd,
pkg: {
workspaces: {
packages: [
"a",
"b"
]
}
}
})
// ->
// Map {
// 'a': '<cwd>/a'
// 'b': '<cwd>/b'
// }Given a folder structure such as:
├── package.json
└── apps
├── a
│ └── package.json
├── b
│ └── package.json
└── c
└── package.jsonconst mapWorkspaces = require('@npmcli/map-workspaces')
await mapWorkspaces({
cwd,
pkg: {
workspaces: [
"apps/*"
]
}
})
// ->
// Map {
// 'a': '<cwd>/apps/a'
// 'b': '<cwd>/apps/b'
// 'c': '<cwd>/apps/c'
// }mapWorkspaces(opts) -> Promise<Map>opts:
pkg: A valid package.json Objectcwd: A String defining the base directory to use when reading globs and paths.ignore: An Array of paths to be ignored when using globs to look for nested package.A Map in which keys are package names and values are the pathnames for each found workspace.
npm-cli-ops
npm-cli+bot@github.com
Estimated unpacked size across 24 packages.
7.2 MB
Includes dependencies.
4 direct · 2 outdated
^13.0.0
14.0.6
^10.0.3
11.0.8
^8.0.0
8.0.1
^5.0.0
5.0.0