npm.io
3.3.1 • Published 1 year ago

@node-kit/lerna-workspace-root

Licence
MIT
Version
3.3.1
Deps
2
Size
11 kB
Vulns
0
Weekly
0

@node-kit/lerna-workspace-root

A simple utility to get the lerna workspace root

NPM version Codacy Badge Test coverage npm download License

Sonar

Install

# 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

Usage

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()

API reference

  • 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:
  1. 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

Issues & Support

Please open an issue here.

License

MIT

Keywords