@techor/read-workspace-packages
TypeScript icon, indicating that this package has built-in type declarations

2.4.6 • Public • Published

Read workspace package.json contents

NPM Version NPM Version NPM package ( download / month ) Follow @mastercorg Github release actions


  • By default, read workspace packages by package.json .workspaces in the current working directory
  • By default, workspace packages in node_modules are excluded

Getting Started

npm install @techor/read-workspace-packages

Preparation

Your monorepo usually looks like this:

.
├── package.json
└── packages
    ├─── a
    │    └─── package.json
    ├─── b
    │    ├─── node_modules
    │    │    └─── fake-module
    │    │         └─── package.json
    │    ├─── bb
    │    │    └─── package.json
    │    └─── package.json
    ├─── c
    └─── d
         └─── package.json

./package.json

{
    "workspaces": ["packages/**"]
}

./packages/d/package.json

{
    "name": "d",
    "private": true
}

Usage

readWorkspacePackages(patterns?, options?): any[]

import readWorkspacePackages from '@techor/read-workspace-packages'

const packages = readWorkspacePackages()
// [{ name: 'a' }, { name: 'b' }, { name: 'd', private: true }, { name: 'bb' }]

const packages = readWorkspacePackages(['packages/*'])
// [{ name: 'a' }, { name: 'b' }, { name: 'd', private: true }]

const publicPackages = readWorkspacePackages()
    .fiter((eachWorkspacePackage) => !eachWorkspacePackage.private)
// [{ name: 'a' }, { name: 'b' }, { name: 'bb' }]

Options

Inherited from fast-glob options

{
    cwd: process.cwd(),
    ignore: ['**/node_modules/**']
}

NPM Version

Package Sidebar

Install

npm i @techor/read-workspace-packages

Homepage

aron.tw

Weekly Downloads

6

Version

2.4.6

License

MIT

Unpacked Size

11.1 kB

Total Files

7

Last publish

Collaborators

  • 1aron