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