@rowanmanning/npm-workspaces
v2.1.0
Published
Get a list of all the npm workspaces found in a package lock file
Readme
@rowanmanning/npm-workspaces
Get a list of all the npm workspaces found in a package-lock.json file.
Requirements
This library requires the following to run:
- Node.js 20+
Usage
Install with npm:
npm install @rowanmanning/npm-workspacesLoad one of the methods into your code with import or require:
import { getPackageWorkspaces } from '@rowanmanning/npm-workspaces';
// or
const { getPackageWorkspaces } = require('@rowanmanning/npm-workspaces');The following exports are available.
getPackageWorkspaces()
A function to list the npm workspaces that a package-lock.json file defines. This function has the following signature:
(packageLock: PackageLock) => string[]PackageLock must be a JavaScript object that is a valid package-lock.json or package-lock.json file. We recommend using @rowanmanning/package-json or @npmcli/package-json.
const workspaces = getPackageWorkspaces(require('./package-lock.json'));
// ['', 'packages/example-1', 'packages/example-2']Contributing
See the central README for a contribution guide and code of conduct.
License
Licensed under the MIT license. Copyright © 2024, Rowan Manning
