@node-kit/yarn-workspace-root
TypeScript icon, indicating that this package has built-in type declarations

3.2.0 • Public • Published

@node-kit/yarn-workspace-root

A simple utility to get the yarn workspace root

NPM version Codacy Badge Test coverage npm download License

Sonar

Install

# use pnpm
$ pnpm install -D @node-kit/yarn-workspace-root

# use yarn
$ yarn add -D @node-kit/yarn-workspace-root

# use npm
$ npm install -D @node-kit/yarn-workspace-root

Usage

use import

import { yarnWorkspaceRoot, yarnWorkspaceRootSync } from '@node-kit/yarn-workspace-root'

yarnWorkspaceRoot()
// or
yarnWorkspaceRootSync()

use require

const { yarnWorkspaceRoot, yarnWorkspaceRootSync } = require('@node-kit/yarn-workspace-root')

yarnWorkspaceRoot()
// or
yarnWorkspaceRootSync()

API reference

  • Usage: yarnWorkspaceRoot(cwd) & yarnWorkspaceRootSync(cwd)
  • Parameters:
Param Description Type Optional value Required Default value
cwd running path string - false -
  • Types:
declare type Manifest =
  | (Record<string, unknown> & {
      packages: any
      workspaces: any
    })
  | null

declare function yarnWorkspaceRoot(cwd?: string): Promise<string | null>

declare function yarnWorkspaceRootSync(cwd?: string): string | null
  • Demos:
  1. simple use
import { yarnWorkspaceRoot, yarnWorkspaceRootSync } from '@node-kit/yarn-workspace-root'

yarnWorkspaceRoot().then(path => {
  console.log('The yarn workspace root is: ', path) // /Users/user/path/of/package/root or null
})
console.log('The yarn workspace root is: ', yarnWorkspaceRootSync()) // /Users/user/path/of/package/root or null

Issues & Support

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i @node-kit/yarn-workspace-root

Weekly Downloads

3,841

Version

3.2.0

License

MIT

Unpacked Size

12.1 kB

Total Files

7

Last publish

Collaborators

  • saqqdy