# use pnpm
$ pnpm install -D @node-kit/lerna-workspace-root
# use yarn
$ yarn add -D @node-kit/lerna-workspace-root
# use npm
$ npm install -D @node-kit/lerna-workspace-root
use import
import { lernaWorkspaceRoot, lernaWorkspaceRootSync } from '@node-kit/lerna-workspace-root'
lernaWorkspaceRoot()
// or
lernaWorkspaceRootSync()
use require
const { lernaWorkspaceRoot, lernaWorkspaceRootSync } = require('@node-kit/lerna-workspace-root')
lernaWorkspaceRoot()
// or
lernaWorkspaceRootSync()
- Usage:
lernaWorkspaceRoot(cwd)
&lernaWorkspaceRootSync(cwd)
- Parameters:
Param | Description | Type | Optional value | Required | Default value |
---|---|---|---|---|---|
cwd | running path | string |
- | false |
- |
- Types:
declare function lernaWorkspaceRoot(cwd?: string): Promise<string | null>
declare function lernaWorkspaceRootSync(cwd?: string): string | null
- Demos:
- simple use
import { lernaWorkspaceRoot, lernaWorkspaceRootSync } from '@node-kit/lerna-workspace-root'
lernaWorkspaceRoot().then(path => {
console.log('The lerna workspace root is: ', path) // /Users/user/path/of/package/root or null
})
console.log('The lerna workspace root is: ', lernaWorkspaceRootSync()) // /Users/user/path/of/package/root or null
Please open an issue here.