@nkzw/find-workspaces
v1.1.0
Published
Utility to find all workspace package paths in a monorepo setup.
Readme
@nkzw/find-workspaces
Utility to find all workspace package paths in a monorepo setup. Can be used for the packageDir setting for the import-x/no-extraneous-dependencies ESLint rule.
Installation
npm install @nkzw/find-workspacesUsage
import findWorkspaces from '@nkzw/find-workspaces';
console.log(findWorkspaces()); // Uses `process.cwd()` by default.
console.log(findWorkspaces('/path/to/your/project'));Supported workspace managers
findWorkspaces supports pnpm, yarn, and npm workspace definitions. When both
pnpm-workspace.yaml and package.json workspaces are present, it unions the
patterns from both files.
pnpm
# pnpm-workspace.yaml
packages:
- 'packages/*'
- 'apps/*'yarn / npm
// package.json
{
"workspaces": ["packages/*", "apps/*"]
}// package.json
{
"workspaces": {
"packages": ["packages/*", "apps/*"]
}
}Usage with ESLint
import findWorkspaces from '@nkzw/find-workspaces';
export default [
{
rules: {
'import-x/no-extraneous-dependencies': [
2,
{ packageDir: findWorkspaces() },
],
},
},
];