@node-kit/yarn-workspace-root
v3.2.0
Published
A simple utility to get the yarn workspace root
Downloads
21,347
Maintainers
Readme
@node-kit/yarn-workspace-root
A simple utility to get the yarn workspace root
Install
# use pnpm
$ pnpm install -D @node-kit/yarn-workspace-root
# use yarn
$ yarn add -D @node-kit/yarn-workspace-root
# use npm
$ npm install -D @node-kit/yarn-workspace-root
Usage
use import
import { yarnWorkspaceRoot, yarnWorkspaceRootSync } from '@node-kit/yarn-workspace-root'
yarnWorkspaceRoot()
// or
yarnWorkspaceRootSync()
use require
const { yarnWorkspaceRoot, yarnWorkspaceRootSync } = require('@node-kit/yarn-workspace-root')
yarnWorkspaceRoot()
// or
yarnWorkspaceRootSync()
API reference
- Usage:
yarnWorkspaceRoot(cwd)
&yarnWorkspaceRootSync(cwd)
- Parameters:
| Param | Description | Type | Optional value | Required | Default value |
| ----- | ------------ | -------- | -------------- | -------- | ------------- |
| cwd | running path | string
| - | false
| - |
- Types:
declare type Manifest =
| (Record<string, unknown> & {
packages: any
workspaces: any
})
| null
declare function yarnWorkspaceRoot(cwd?: string): Promise<string | null>
declare function yarnWorkspaceRootSync(cwd?: string): string | null
- Demos:
- simple use
import { yarnWorkspaceRoot, yarnWorkspaceRootSync } from '@node-kit/yarn-workspace-root'
yarnWorkspaceRoot().then(path => {
console.log('The yarn workspace root is: ', path) // /Users/user/path/of/package/root or null
})
console.log('The yarn workspace root is: ', yarnWorkspaceRootSync()) // /Users/user/path/of/package/root or null
Issues & Support
Please open an issue here.