npm package: @nnniyaz/label-run
Description: Run shell commands sequentially with prefixed, colorized output
Author: Niyaz Nassyrov
Latest version: 0.1.0

# @nnniyaz/label-run

Run shell commands **sequentially** with prefixed, colorized output — so you always see which command produced which line.

* [English](#description)
* [Русский](#описание)

> Requires **Node.js ≥ 18**.

---

## Description

Run shell commands sequentially with prefixed, colorized output so you can easily identify which command is producing which output. Useful for running multiple commands in sequence and keeping their outputs organized.

### Installation

```bash
npm i -D @nnniyaz/label-run
# or globally:
# npm i -g @nnniyaz/label-run
```

### Usage (CLI)

**If installed locally:**

```bash
npx label-run "LINT:npm run lint" "BUILD:npm run build" "TEST:npm test"
```

**Without installing (scoped package via npx):**

```bash
npx -y @nnniyaz/label-run label-run "LINT:npm run lint" "BUILD:npm run build" "TEST:npm test"
# or pin latest explicitly:
# npx -y @nnniyaz/label-run@latest label-run "..."
```

**Help**

```bash
label-run --help
```

### Usage (API)

```ts
import { runOne, runMany } from "@nnniyaz/label-run";

// Runs one command with a label
await runOne("ECHO", "echo hello", { cwd: process.cwd(), env: { FOO: "bar" } });

// Runs several commands in order; stops on first failure
await runMany(
  ["A:echo first", "B:echo second"],
  { cwd: process.cwd(), env: { CI: "true" } }
);
```

**API**

* `runOne(label: string, cmd: string, opts?: { cwd?: string; env?: NodeJS.ProcessEnv }) => Promise<void>`
* `runMany(items: string[], opts?: { cwd?: string; env?: NodeJS.ProcessEnv }) => Promise<void>`
  If a command exits with non-zero code, the promise rejects (CLI exits with **code 1**).

> Output format: each line is prefixed as `[LABEL] ...`. Colors are ANSI; they’re enabled on TTY.

---

## Описание

Запускайте shell-команды **последовательно** с меткой-префиксом и цветным выводом — сразу видно, какая команда печатает строку.

### Установка

```bash
npm i -D @nnniyaz/label-run
# или глобально:
# npm i -g @nnniyaz/label-run
```

### Использование (CLI)

**Если пакет установлен локально:**

```bash
npx label-run "LINT:npm run lint" "BUILD:npm run build" "TEST:npm test"
```

**Без установки (через npx для scoped-пакета):**

```bash
npx -y @nnniyaz/label-run label-run "LINT:npm run lint" "BUILD:npm run build" "TEST:npm test"
```

**Справка**

```bash
label-run --help
```

### Использование (API)

```ts
import { runOne, runMany } from "@nnniyaz/label-run";

await runOne("ECHO", "echo привет");
await runMany(["A:echo первый", "B:echo второй"]);
```

**Поведение**

* Останавливается на **первой ошибке**.
* Возвращает код **0** при успехе, **1** при ошибке (удобно для CI).
* Поддерживаются опции `cwd` и `env`.

---

### Notes

* **Quoting:** на Unix используйте `"..."`, на Windows PowerShell иногда удобнее `'...'` или экранировать кавычки.
* **First `:` splits label and command.** Everything after the first colon is treated as the command (Windows `C:\\...` безопасно).

---

# package.json

```json
{
  "name": "@nnniyaz/label-run",
  "version": "0.1.0",
  "description": "Run shell commands sequentially with prefixed, colorized output",
  "license": "MIT",
  "author": "Niyaz Nassyrov",
  "type": "module",
  "engines": { "node": ">=18" },
  "bin": {
    "label-run": "./bin/label-run.js"
  },
  "main": "./src/index.js",
  "exports": {
    ".": "./src/index.js"
  },
  "keywords": [
    "cli",
    "spawn",
    "prefix",
    "color",
    "runner",
    "sequential",
    "scripts"
  ],
  "files": ["bin", "src", "README.md", "LICENSE"],
  "sideEffects": false,
  "scripts": {
    "test": "node bin/label-run.js --help",
    "prepublishOnly": "node -e \"console.log('publishing @nnniyaz/label-run')\""
  }
}
```