# run-scripts-util

> Organize npm package.json scripts into groups of easy-to-manage commands (CLI tool designed for use in npm package.json scripts)

Latest version **1.4.0** (published 2026-08-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install run-scripts-util
pnpm add run-scripts-util
yarn add run-scripts-util
bun add run-scripts-util
```

Provides the commands `run-scripts`, `run-scripts-util`.

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2026-08-19 |
| First published | 2022-10-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 3 |
| Unpacked size | 18.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Center Key |
| Maintainers | pilafmon |
| Keywords | asynchronous, build, cli, npm-scripts, npm, parallel, scripts, sequential, serial, synchronous, task |

## Links

- npm: https://www.npmjs.com/package/run-scripts-util
- Repository: https://github.com/center-key/run-scripts-util
- Issues: https://github.com/center-key/run-scripts-util/issues
- npm.io page: https://npm.io/package/run-scripts-util

## Dependencies (3)

- [chalk](https://npm.io/package/chalk.md) ~6.0
- [fancy-log](https://npm.io/package/fancy-log.md) ~2.0
- [cli-argv-util](https://npm.io/package/cli-argv-util.md) ~1.5

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.4.0 (latest) — 2026-08-19
- 1.3.9 — 2026-08-16
- 1.3.8 — 2026-07-01
- 1.3.7 — 2026-06-24
- 1.3.6 — 2026-06-04
- 1.3.5 — 2026-02-28
- 1.3.4 — 2025-11-06
- 1.3.3 — 2025-08-25
- 1.3.2 — 2025-03-05
- 1.3.1 — 2024-08-14
- 1.3.0 — 2024-07-17
- 1.2.6 — 2024-07-02
- 1.2.5 — 2024-02-18
- 1.2.4 — 2024-01-04
- 1.2.3 — 2023-10-02
- … 11 more at https://npm.io/package/run-scripts-util/versions

## README

# run-scripts-util
<img src=https://centerkey.com/graphics/center-key-logo.svg align=right width=200 alt=logo>

_Organize npm package.json scripts into groups of easy-to-manage commands (CLI tool designed for use in npm package.json scripts)_

[![License:MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/center-key/run-scripts-util/blob/main/LICENSE.txt)
[![npm](https://img.shields.io/npm/v/run-scripts-util.svg)](https://www.npmjs.com/package/run-scripts-util)
[![Build](https://github.com/center-key/run-scripts-util/actions/workflows/run-spec-on-push.yaml/badge.svg)](https://github.com/center-key/run-scripts-util/actions/workflows/run-spec-on-push.yaml)

**run-scripts-util** reads the `runScriptsConfig` settings in your **package.son** to get
groups (arrays) of commands to execute.

**Turn the traditional hard-to-follow commands:**
```json
"scripts": {
   "clean": "rimraf build dist",
   "compile-ts": "tsc",
   "compile-less": "lessc src/web-app/style.less build/web-app/style.css",
   "compile-html": "replacer src/web-app --ext=.html build/web-app",
   "graphics": "copy-folder src/graphics build/web-app/graphics",
   "pretest": "npm run clean && npm run compile-ts && npm run compile-less && npm run compile-html && npm run graphics",
   "test": "mocha spec"
},
```
**into easy-to-read named groups (arrays) of commands:**
```json
"runScriptsConfig": {
   "clean": [
      "rimraf build dist"
   ],
   "compile": [
      "tsc",
      "lessc       src/web-app/style.less  build/web-app/style.css",
      "replacer    src/web-app --ext=.html build/web-app",
      "copy-folder src/graphics            build/web-app/graphics"
   ]
},
"scripts": {
   "pretest": "run-scripts clean compile",
   "test": "mocha spec"
},
```
Each group of commands is executed in order, and the commands within each group are by default
executed in serial (synchronously) but can optionally be executed in parallel (asynchronously).

![screenshot](screenshot.png)

## A) Setup
Install package for node:
```shell
$ npm install --save-dev run-scripts-util
```

## B) Usage
### 1. Synopsis
```
run-scripts [GROUP1] [GROUP2] [GROUP3] [...]
```
Parameters:
Each parameter is the name of a group of individual tasks.&nbsp;
The groups are defined in the `runScriptsConfig` object of your project's **package.json** file.

### 2. npm package.json scripts
Use `run-scripts` in the `"scripts"` section of your **package.json** file and add a
parameter naming the key in `runScriptsConfig` holding the group (array) of commands to
execute.

Example **package.json** scripts:
```json
"scripts": {
   "build": "run-scripts clean compile",
},
```

### 3. CLI flags
Command-line flags:
| Flag                  | Description                                                     | Value      |
| --------------------- | ----------------------------------------------------------------| ---------- |
| `--continue-on-error` | Do not throw an exception if a task exits with an error status. | N/A        |
| `--note`              | Place to add a comment only for humans.                         | **string** |
| `--only`              | Execute just one command in the group (starts with 1).          | **number** |
| `--parallel`          | Execute all commands within each group asynchronously.          | N/A        |
| `--quiet`             | Suppress informational messages.                                | N/A        |
| `--verbose`           | Add script group name to informational messages.                | N/A        |

### 4. Examples
   - `run-scripts clean compile`<br>
   Executes the `clean` group of commands and then execute the `compile` group fo commands.

   - `run-scripts clean compile --quiet`<br>
   Does not display information messages.

   - `run-scripts clean compile --quiet '--note=Listen to silence'`<br>
   Notes are handy for adding a short comment.

   - `run-scripts compile --verbose --only=2`<br>
   Executes just the second command in the `compile` group.

   - `run-scripts lint watch --parallel`<br>
   Executes all the `lint` commands in parallel and then after all the commands are finished executes
   the `watch` commands in parallel.

> [!NOTE]
> _Single quotes in commands are normalized so they work cross-platform and avoid the errors often encountered on Microsoft Windows._

### 5. Skip a command
To _comment out_ a command prepend two slashes (`//`) to the command.

In the example below, the first `tsc` command will be skipped while the `tsc --verbose` command will be executed:
 ```json
"runScriptsConfig": {
   "compile": [
      "//tsc",
      "tsc --verbose",
      "lessc src/web-app/style.less build/web-app/style.css"
   ]
}
```

### 6. Debug a command
To manually run a single command, use `npx` from the terminal plus the `--only` flag.

For example, to run the third command in the `compile` group by itself:
```shell
$ npx run-scripts compile --only=3
```

## C) Application Code
Even though **run-scripts-util** is primarily intended for build scripts, the package can be used programmatically in ESM and TypeScript projects.

Example:
``` typescript
import { runScripts } from 'run-scripts-util';

const options = { quiet: false };
runScripts.exec('compile', options);
runScripts.execParallel('watch', options);
```

See the **TypeScript Declarations** at the top of [run-scripts.ts](src/run-scripts.ts) for documentation.

<br>

---
[MIT License](LICENSE.txt)

[🛡️ npm Security Aggregator](https://center-key.github.io/npm-security-aggregator/?package=run-scripts-util)

See the `runScriptsConfig` section of [`package.json`](package.json) for a clean way to organize build tasks:
   - 🎋 [`add-dist-header`](https://github.com/center-key/add-dist-header) &mdash;&nbsp; _Prepend a one-line banner comment (with license notice) to distribution files_
   - 📄 [`copy-file-util`](https://github.com/center-key/copy-file-util) &mdash;&nbsp; _Copy or rename a file with optional package version number_
   - 📂 [`copy-folder-util`](https://github.com/center-key/copy-folder-util) &mdash;&nbsp; _Recursively copy files from one folder to another folder_
   - 🪺 [`recursive-exec`](https://github.com/center-key/recursive-exec) &mdash;&nbsp; _Run a command on each file in a folder and its subfolders_
   - 🔍 [`replacer-util`](https://github.com/center-key/replacer-util) &mdash;&nbsp; _Find and replace strings or template outputs in text files_
   - 🔢 [`rev-web-assets`](https://github.com/center-key/rev-web-assets) &mdash;&nbsp; _Revision web asset filenames with cache busting content hash fingerprints_
   - 🚆 [`run-scripts-util`](https://github.com/center-key/run-scripts-util) &mdash;&nbsp; _Organize npm package.json scripts into groups of easy-to-manage commands_
   - 🚦 [`w3c-html-validator`](https://github.com/center-key/w3c-html-validator) &mdash;&nbsp; _Check the markup validity of HTML files using the W3C validator_

---
_Source: https://npm.io/package/run-scripts-util · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
