# @workspace-builder/tools

> Helper methods for workspace-builder build method modules

Latest version **1.0.0** (published 2020-01-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @workspace-builder/tools
pnpm add @workspace-builder/tools
yarn add @workspace-builder/tools
bun add @workspace-builder/tools
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-01-15 |
| First published | 2019-01-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 4.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Lily Scott |
| Maintainers | suchipi |

## Links

- npm: https://www.npmjs.com/package/@workspace-builder/tools
- npm.io page: https://npm.io/package/@workspace-builder/tools

## Dependencies (2)

- [chalk](https://npm.io/package/chalk.md) ^2.4.2
- [shelljs](https://npm.io/package/shelljs.md) ^0.8.3

## Recent versions

- 1.0.0 (latest) — 2020-01-15
- 0.4.0 — 2019-02-10
- 0.2.0 — 2019-01-20
- 0.1.0 — 2019-01-12

## README

# `@workspace-builder/tools`

Some helper utilities for use from within a [`workspace-builder`](https://npm.im/workspace-builder) builder module.

## Usage/API

```js
const {
  rootDir,
  workspaceDir,
  bin,
  exec,
  spawn,
} = require("@workspace-builder/tools");

// rootDir: get the absolute path to the project root dir or a path relative to the project root dir.
rootDir(); // eg "/Users/suchipi/Code/my-project"
rootDir(".babelrc"); // eg "/Users/suchipi/Code/my-project/.babelrc"
rootDir(".storybook", "webpack.config.js"); // eg "/Users/suchipi/Code/my-project/.storybook/webpack.config.js"

// workspaceDir: get the absolute path to the current workspace, or a path relative to the current workspace dir.
workspaceDir(); // eg "/Users/suchipi/Code/my-project/packages/my-package"
workspaceDir(".babelrc"); // eg "/Users/suchipi/Code/my-project/packages/my-package/.babelrc"
workspaceDir(".storybook", "webpack.config.js"); // eg "/Users/suchipi/Code/my-project/packages/my-package/.storybook/webpack.config.js"

// bin: get the absolute path to a bin installed from npm. Searches <workspaceDir>/node_modules/.bin first, and goes to <rootDir>/node_modules/.bin if it doesn't exist there.
bin("babel"); // eg "/Users/suchipi/Code/my-project/node_modules/.bin/babel"

// exec: Run a command-line script from within the workspace dir and wait for it to complete. If it exits with a nonzero status code, an error will be thrown.
exec(`${bin("babel")} src --out-dir dist`); // runs eg "/Users/suchipi/Code/my-project/node_modules/.bin/babel src --out-dir dist" from within the workspace dir

// spawn: Run a command-line script from within the workspace dir and DO NOT wait for it to complete.
spawn(`${bin("babel")} --watch src --out-dir dist`); // runs eg "/Users/suchipi/Code/my-project/node_modules/.bin/babel src --out-dir dist" from within the workspace dir
```

## License

MIT

---
_Source: https://npm.io/package/@workspace-builder/tools · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
