# list-workspace

> List all packages in a workspace, or all workspaces in a monorepo.

Latest version **1.0.1** (published 2023-07-26) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-07-26 |
| First published | 2023-07-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 4 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Connor White |
| Maintainers | bconnorwhite |
| Keywords | workspace, list, packages, monorepo, workspaces, find, name, names |

## Links

- npm: https://www.npmjs.com/package/list-workspace
- Repository: https://github.com/bconnorwhite/list-workspace
- Homepage: https://github.com/bconnorwhite/list-workspace#readme
- Issues: https://github.com/bconnorwhite/list-workspace/issues
- npm.io page: https://npm.io/package/list-workspace

## Dependencies (4)

- [globby](https://npm.io/package/globby.md) ^13.2.2
- [is-monorepo](https://npm.io/package/is-monorepo.md) ^1.0.1
- [package-run](https://npm.io/package/package-run.md) ^3.0.1
- [workspace-root](https://npm.io/package/workspace-root.md) ^3.1.1

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2023-07-26
- 1.0.0 — 2023-07-25

## README

<!--BEGIN HEADER-->
<div id="top" align="center">
  <h1>list-workspace</h1>
  <a href="https://npmjs.com/package/list-workspace">
    <img alt="NPM" src="https://img.shields.io/npm/v/list-workspace.svg">
  </a>
  <a href="https://github.com/bconnorwhite/list-workspace">
    <img alt="TypeScript" src="https://img.shields.io/github/languages/top/bconnorwhite/list-workspace.svg">
  </a>
</div>

<br />

<blockquote align="center">List all packages in a workspace, or all workspaces in a monorepo.</blockquote>

<br />

_If I should maintain this repo, please ⭐️_
<a href="https://github.com/bconnorwhite/list-workspace">
  <img align="right" alt="GitHub stars" src="https://img.shields.io/github/stars/bconnorwhite/list-workspace?label=%E2%AD%90%EF%B8%8F&style=social">
</a>

_DM me on [Twitter](https://twitter.com/bconnorwhite) if you have questions or suggestions._
<a href="https://twitter.com/bconnorwhite">
  <img align="right" alt="Twitter" src="https://img.shields.io/twitter/url?label=%40bconnorwhite&style=social&url=https%3A%2F%2Ftwitter.com%2Fbconnorwhite">
</a>

---
<!--END HEADER-->

## Installation

```sh
npm install list-workspace
```

```sh
yarn add list-workspace
```

```sh
pnpm add list-workspace
```

```sh
bun add list-workspace
```

## Usage
```js
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/*");
```
<!--BEGIN FOOTER-->

<br />

<h2 id="dependencies">Dependencies<a href="https://www.npmjs.com/package/list-workspace?activeTab=dependencies"><img align="right" alt="dependencies" src="https://img.shields.io/librariesio/release/npm/list-workspace.svg"></a></h2>

- [globby](https://www.npmjs.com/package/globby): User-friendly glob matching
- [is-monorepo](https://www.npmjs.com/package/is-monorepo): Check if the working directory is in a monorepo.
- [package-run](https://www.npmjs.com/package/package-run): Node API for running package.json scripts. Supports yarn, npm, and pnpm.
- [workspace-root](https://www.npmjs.com/package/workspace-root): A simple utility to get the workspace root

<br />

<h3>Dev Dependencies</h3>

- [autorepo](https://www.npmjs.com/package/autorepo): Autorepo abstracts away your dev dependencies, providing a single command to run all of your scripts.

<br />

<h2 id="license">License <a href="https://opensource.org/licenses/MIT"><img align="right" alt="license" src="https://img.shields.io/npm/l/list-workspace.svg"></a></h2>

[MIT](https://opensource.org/licenses/MIT)
<!--END FOOTER-->

---
_Source: https://npm.io/package/list-workspace · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
