Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

resolve-workspace-root

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resolve-workspace-root

Resolve the workspace root using bun, npm, pnpm, or yarn


Version published
Weekly downloads
6.2K
increased by28.92%
Maintainers
0
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 10 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc