resolve-workspace-root
Resolve the workspace root using bun, npm, pnpm, or yarn
Last updated a month ago by bycedric .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install resolve-workspace-root 
SYNC missed versions from official npm registry.

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));

with ❤️  Cedric

Current Tags

  • 2.0.0                                ...           latest (a month ago)

3 Versions

  • 2.0.0                                ...           a month ago
  • 1.0.1                                ...           3 months ago
  • 1.0.0                                ...           3 months ago
Maintainers (1)
Downloads
Total 1
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (13)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE