resolve-workspace-root
v2.0.0
Published
Resolve the workspace root using bun, npm, pnpm, or yarn
Downloads
1,485,466
Maintainers
Readme
resolve-workspace-root
Resolve the root of a workspace using bun, npm, pnpm, or yarn.
- For bun, npm, and yarn - it looks for a parent package.json file, containing the
workspaces
config. - For pnpm - it looks for a package.json and pnpm-workspaces.yaml file, containing the workspaces config.
🚀 How to use it
This package supports both synchronous and asynchronous lookups.
import { resolveWorkspaceRoot, resolveWorkspaceRootAsync } from 'resolve-workspace-root';
// Synchronous lookup, supporting bun, npm, pnpm, and yarn
const workspaceRoot = resolveWorkspaceRoot(__dirname);
// Synchronous lookup, supporting only bun, npm, and yarn
const workspaceRoot = resolveWorkspaceRoot(__dirname, { packageWorkspaces: false });
// Synchronous lookup, supporting only pnpm
const workspaceRoot = resolveWorkspaceRoot(__dirname, { pnpmWorkspaces: false });
// Asynchronous lookup, supporting bun, npm, pnpm, and yarn
const workspaceRoot = await resolveWorkspaceRootAsync(__dirname);
// Asynchronous lookup, supporting only bun, npm, and yarn
const workspaceRoot = await resolveWorkspaceRootAsync(__dirname, { packageWorkspaces: false });
// Asynchronous lookup, supporting only pnpm
const workspaceRoot = await resolveWorkspaceRootAsync(__dirname, { pnpmWorkspaces: false });
import { getWorkspaceGlobs, getWorkspaceGlobsAsync } from 'resolve-workspace-root';
// Synchronous lookup, supporting bun, npm, pnpm, and yarn
const workspaces = getWorkspaceGlobs(resolveWorkspaceRoot(__dirname));
// Asynchronous lookup, supporting bun, npm, pnpm, and yarn
const workspaces = await getWorkspaceGlobsAsync(resolveWorkspaceRoot(__dirname));