npm.io
2.4.6 • Published 3 years ago

@techor/query-workspaces

Licence
MIT
Version
2.4.6
Deps
3
Size
11 kB
Vulns
0
Weekly
0
Stars
11

Query workspaces with package.json

NPM Version NPM Version NPM package ( download / month ) Follow @mastercorg Github release actions


  • By default, read .workspaces of package.json in the current working directory
  • By default, workspaces in node_modules are excluded

Getting Started

npm install @techor/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 '@techor/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/**']
}

NPM Version

Keywords