@node-kit/yarn-workspace-info
v3.3.0
Published
A simple utility to get the yarn workspace information
Downloads
1,325
Maintainers
Readme
@node-kit/yarn-workspace-info
A simple utility to get the yarn workspace information
Install
# use pnpm
$ pnpm install -D @node-kit/yarn-workspace-info
# use yarn
$ yarn add -D @node-kit/yarn-workspace-info
# use npm
$ npm install -D @node-kit/yarn-workspace-info
Usage
use import
import { yarnWorkspaceInfo, yarnWorkspaceInfoSync } from '@node-kit/yarn-workspace-info'
yarnWorkspaceInfo()
// or
yarnWorkspaceInfoSync()
use require
const { yarnWorkspaceInfo, yarnWorkspaceInfoSync } = require('@node-kit/yarn-workspace-info')
yarnWorkspaceInfo()
// or
yarnWorkspaceInfoSync()
API reference
- Usage:
yarnWorkspaceInfo(cwd)
&yarnWorkspaceInfoSync(cwd)
- Parameters:
| Param | Description | Type | Optional value | Required | Default value |
| ----- | ------------ | -------- | -------------- | -------- | ------------- |
| cwd | running path | string
| - | false
| - |
- Types:
declare type ManifestInfo = Record<string, unknown> & {
workspaces: string | string[]
}
declare type WorkspaceInfo = Record<
string,
{
path: string
}
>
declare function yarnWorkspaceInfo(cwd?: string): Promise<WorkspaceInfo | null>
declare function yarnWorkspaceInfoSync(cwd?: string): WorkspaceInfo | null
- Demos:
- simple use
import { yarnWorkspaceInfo, yarnWorkspaceInfoSync } from '@node-kit/yarn-workspace-info'
yarnWorkspaceInfo({
cwd,
packageManager: 'pnpm'
}).then(data => {
console.log('The yarn workspace info is: ', data) // { projectA: { path: 'packages/projectA' } }
})
console.log('The yarn workspace info is: ', yarnWorkspaceInfoSync()) // { projectA: { path: 'packages/projectA' } }
Issues & Support
Please open an issue here.