to-query-workspaces
v1.5.5
Published
Query workspaces with package.json
Downloads
890
Maintainers
Readme
- By default, read
.workspaces
of package.json in the current working directory - By default, workspaces in node_modules are excluded
Getting Started
npm install to-query-workspaces
Preparation
Your monorepo usually looks like this:
.
├── package.json
└── packages
+ ├─── a
│ └─── package.json
+ ├─── b
│ ├─── node_modules
│ │ └─── fake-module
│ │ └─── package.json
+ │ ├─── bb
│ │ └─── package.json
│ └─── package.json
└─── c
./package.json
{
"workspaces": ["packages/**"]
}
Usage
queryWorkspaces(patterns?, options?): string[]
import queryWorkspaces from 'to-query-workspaces'
const workspaces = queryWorkspaces()
// ['packages/a', 'packages/b', 'packages/b/bb']
const workspaces = queryWorkspaces(['packages/*'])
// ['packages/a', 'packages/b']
Options
Inherited from fast-glob options
{
cwd: process.cwd(),
ignore: ['**/node_modules/**']
}