workspace-root
v3.3.1
Published
A simple utility to get the workspace root
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-rootUsage
use import
import { workspaceRoot, workspaceRootSync } from 'workspace-root'
workspaceRoot()
// or
workspaceRootSync()use require
const { workspaceRoot, workspaceRootSync } = require('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 '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 nullIssues & Support
Please open an issue here.
