1.0.1 • Published 9 months ago

list-workspace v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

If I should maintain this repo, please ⭐️

DM me on Twitter if you have questions or suggestions.


Installation

npm install list-workspace
yarn add list-workspace
pnpm add list-workspace
bun add list-workspace

Usage

import {
  listWorkspaces,
  listWorkspacesPackageJSONs
  listWorkspace,
  listWorkspacePackageJSON
} from "which-pm-lockfile";

/**
 * List all workspace package directories in a monorepo.
 * 
 * Returns the absolute path to each workspace package directory.
 * Returns `undefined` if not in a monorepo.
 * 
 * Example: `["/path/to/packages/foo", "/path/to/packages/bar"]`
 */
const workspaces = await listWorkspaces();

/**
 * List all workspace package package.json files in a monorepo.
 * 
 * Returns the absolute path to each workspace package.json.
 * Returns `undefined` if not in a monorepo.
 * 
 * Example: `["/path/to/packages/foo/package.json", "/path/to/apps/bar/package.json"]`
 */
const workspacesPackageJSONs = await listWorkspacesPackageJSONs();

/**
 * List all package directories in a specific workspace within a monorepo.
 * 
 * Returns the absolute path to each workspace package directory.
 * Returns undefined if not in a monorepo, or if the workspace does not exist.
 * 
 * Example: ["/path/to/packages/foo/package"]
 */
const workspace = await listWorkspace("packages/*");

/**
 * List all package package.jsons in a specific workspace within a monorepo.
 * 
 * Returns the absolute path to each workspace package's package.json.
 * Returns undefined if not in a monorepo, or if the workspace does not exist.
 * 
 * Example: ["/path/to/packages/foo/package/package.json"]
 */
const workspacePackageJSONs= await listWorkspacePackageJSON("packages/*");
  • globby: User-friendly glob matching
  • is-monorepo: Check if the working directory is in a monorepo.
  • package-run: Node API for running package.json scripts. Supports yarn, npm, and pnpm.
  • workspace-root: A simple utility to get the workspace root
  • autorepo: Autorepo abstracts away your dev dependencies, providing a single command to run all of your scripts.

MIT