šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

workspace-root

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

workspace-root

A simple utility to get the workspace root

3.3.1
latest
Source
npm
Version published
Weekly downloads
25K
8.19%
Maintainers
1
Weekly downloads
Ā 
Created
Source

workspace-root

A simple utility to get the workspace root

NPM version Codacy Badge Test coverage npm download License

Sonar

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 'workspace-root'

workspaceRoot()
// or
workspaceRootSync()

use require

const { workspaceRoot, workspaceRootSync } = require('workspace-root')

workspaceRoot()
// or
workspaceRootSync()

API reference

  • Usage: workspaceRoot(cwd) & workspaceRootSync(cwd)
  • Parameters:
ParamDescriptionTypeOptional valueRequiredDefault value
cwdrunning pathstring-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 null

Issues & Support

Please open an issue here.

License

MIT

Keywords

node-kit

FAQs

Package last updated on 26 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts