Skip to content

Commit

Permalink
Release v1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilafian committed Jul 21, 2023
1 parent 261dd67 commit 9fd6b5a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ Examples:
Execute all the `lint` commands in parallel and after all the commands are finished execute
the `watch` commands in parallel.

### 5. Skip a command
### 4. Skip a command
To _comment out_ a command prepend a dash (`-`) to the command.

In the example below, the first `tsc` command will be skipped while the `tsc --force --verbose` command will be executed:
In the example below, the first `tsc` command will be skipped while the `tsc --verbose` command will be executed:
```json
"runScriptsConfig": {
"compile": [
"- tsc",
"tsc --force --verbose",
"tsc --verbose",
"lessc src/web-app/style.less build/web-app/style.css"
]
}
Expand Down
2 changes: 1 addition & 1 deletion dist/run-scripts.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! run-scripts-util v1.2.0 ~~ https://github.com/center-key/run-scripts-util ~~ MIT License
//! run-scripts-util v1.2.1 ~~ https://github.com/center-key/run-scripts-util ~~ MIT License

export type Settings = {
only: number | null;
Expand Down
14 changes: 10 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.0 ~~ https://github.com/center-key/run-scripts-util ~~ MIT License
//! run-scripts-util v1.2.1 ~~ https://github.com/center-key/run-scripts-util ~~ MIT License

import { spawn, spawnSync } from 'node:child_process';
import chalk from 'chalk';
Expand All @@ -19,7 +19,7 @@ const runScripts = {
const logger = createLogger(settings);
if (!Array.isArray(commands) || commands.some(command => typeof command !== 'string'))
throw Error('[run-scripts-util] Cannot find commands: ' + group);
const execCommand = (command, step) => {
const execCommand = (step, command) => {
const startTime = Date.now();
if (!settings.quiet)
console.log();
Expand All @@ -31,8 +31,14 @@ const runScripts = {
throw Error(errorMessage() + '\nCommand: ' + command);
logger(...logItems, chalk.green('done'), chalk.white(`(${Date.now() - startTime}ms)`));
};
const active = (step) => settings.only === null || step === settings.only;
commands.forEach((command, index) => active(index + 1) && execCommand(command, index + 1));
const skip = (step, command) => {
const inactive = step === settings.only;
const commentedOut = command.startsWith('-');
if (commentedOut)
logger(chalk.yellow('skipping'), arrow, command);
return inactive || commentedOut;
};
commands.forEach((command, index) => !skip(index + 1, command) && execCommand(index + 1, command));
},
execParallel(group, options) {
const defaults = {
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.0",
"version": "1.2.1",
"description": "Organize npm scripts into named groups of easy to manage commands (CLI tool designed for use in npm scripts)",
"license": "MIT",
"type": "module",
Expand Down

0 comments on commit 9fd6b5a

Please sign in to comment.