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