Skip to content

Commit

Permalink
Release v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilafian committed Jul 17, 2024
1 parent d9da610 commit f36696e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ Example **package.json** scripts:
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 |
| `--continue-on-error` | Do not throw an exception if a task exits with an error status. | N/A |

### 3. Example CLI usage
Examples:
Expand Down
3 changes: 2 additions & 1 deletion dist/run-scripts.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! run-scripts-util v1.2.6 ~~ https://github.com/center-key/run-scripts-util ~~ MIT License
//! run-scripts-util v1.3.0 ~~ https://github.com/center-key/run-scripts-util ~~ MIT License

export type Settings = {
continueOnError: boolean;
only: number | null;
quiet: boolean;
verbose: boolean;
Expand Down
12 changes: 8 additions & 4 deletions dist/run-scripts.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! run-scripts-util v1.2.6 ~~ https://github.com/center-key/run-scripts-util ~~ MIT License
//! run-scripts-util v1.3.0 ~~ https://github.com/center-key/run-scripts-util ~~ MIT License

import { spawn, spawnSync } from 'node:child_process';
import chalk from 'chalk';
Expand All @@ -9,6 +9,7 @@ const createLogger = (settings) => (...args) => !settings.quiet && log(chalk.gra
const runScripts = {
exec(group, options) {
const defaults = {
continueOnError: false,
only: null,
quiet: false,
verbose: false,
Expand All @@ -28,9 +29,11 @@ const runScripts = {
logItems.push(chalk.yellow(step), arrow);
logger(...logItems, chalk.cyanBright(command));
const task = spawnSync(command, { shell: true, stdio: 'inherit' });
const errorMessage = () => `[run-scripts-util] Task: ${group} (step ${step}), Status: ${task.status}`;
if (task.status !== 0)
throw Error(errorMessage() + '\nCommand: ' + command);
const errorMessage = () => `Task: ${group} (step ${step}), Status: ${task.status}`;
if (task.status !== 0 && settings.continueOnError)
logger(chalk.red('ERROR'), chalk.white('-->'), errorMessage());
if (task.status !== 0 && !settings.continueOnError)
throw Error('[run-scripts-util] ' + errorMessage() + '\nCommand: ' + command);
logger(...logItems, chalk.green('done'), chalk.white(`(${Date.now() - startTime}ms)`));
};
const skip = (step, command) => {
Expand All @@ -44,6 +47,7 @@ const runScripts = {
},
execParallel(group, options) {
const defaults = {
continueOnError: false,
only: null,
quiet: false,
verbose: false,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "run-scripts-util",
"version": "1.2.6",
"version": "1.3.0",
"description": "Organize npm package.json scripts into named groups of easy to manage commands (CLI tool designed for use in npm package.json scripts)",
"license": "MIT",
"type": "module",
Expand Down

0 comments on commit f36696e

Please sign in to comment.