{"id":22897274,"url":"https://github.com/center-key/run-scripts-util","last_synced_at":"2025-05-07T22:06:58.674Z","repository":{"id":61839074,"uuid":"555237514","full_name":"center-key/run-scripts-util","owner":"center-key","description":"🚆 Organize package.json scripts into named groups of easy to manage commands","archived":false,"fork":false,"pushed_at":"2025-03-05T02:37:42.000Z","size":435,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T22:06:50.992Z","etag":null,"topics":["build","cli","npm","scripts"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/center-key.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-21T07:35:26.000Z","updated_at":"2025-03-05T02:37:33.000Z","dependencies_parsed_at":"2023-11-10T12:48:09.259Z","dependency_job_id":"3b99f1f8-cfe5-457a-995d-2a611520c95a","html_url":"https://github.com/center-key/run-scripts-util","commit_stats":{"total_commits":45,"total_committers":1,"mean_commits":45.0,"dds":0.0,"last_synced_commit":"8a83cae07e5306fc9b1b7b4e4ed67537480e6499"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/center-key%2Frun-scripts-util","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/center-key%2Frun-scripts-util/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/center-key%2Frun-scripts-util/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/center-key%2Frun-scripts-util/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/center-key","download_url":"https://codeload.github.com/center-key/run-scripts-util/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252961837,"owners_count":21832196,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["build","cli","npm","scripts"],"created_at":"2024-12-14T00:16:24.129Z","updated_at":"2025-05-07T22:06:58.661Z","avatar_url":"https://github.com/center-key.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# run-scripts-util\n\u003cimg src=https://centerkey.com/graphics/center-key-logo.svg align=right width=200 alt=logo\u003e\n\n_Organize npm package.json scripts into groups of easy to manage commands (CLI tool designed for use in npm package.json scripts)_\n\n[![License:MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/center-key/run-scripts-util/blob/main/LICENSE.txt)\n[![npm](https://img.shields.io/npm/v/run-scripts-util.svg)](https://www.npmjs.com/package/run-scripts-util)\n[![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)\n\n**run-scripts-util** reads the `runScriptsConfig` settings in your **package.son** to get\ngroups (arrays) of commands to execute.\n\n**Turn the traditional hard-to-follow commands:**\n```json\n\"scripts\": {\n   \"clean\": \"rimraf build dist\",\n   \"compile-ts\": \"tsc\",\n   \"compile-less\": \"lessc src/web-app/style.less build/web-app/style.css\",\n   \"compile-html\": \"replacer src/web-app --ext=.html build/web-app\",\n   \"graphics\": \"copy-folder src/graphics build/web-app/graphics\",\n   \"pretest\": \"npm run clean \u0026\u0026 npm run compile-ts \u0026\u0026 npm run compile-less \u0026\u0026 npm run compile-html \u0026\u0026 npm run graphics\",\n   \"test\": \"mocha spec\"\n},\n```\n**into easy-to-read named groups (arrays) of commands:**\n```json\n\"runScriptsConfig\": {\n   \"clean\": [\n      \"rimraf build dist\"\n   ],\n   \"compile\": [\n      \"tsc\",\n      \"lessc       src/web-app/style.less  build/web-app/style.css\",\n      \"replacer    src/web-app --ext=.html build/web-app\",\n      \"copy-folder src/graphics            build/web-app/graphics\"\n   ]\n},\n\"scripts\": {\n   \"pretest\": \"run-scripts clean compile\",\n   \"test\": \"mocha spec\"\n},\n```\nEach group of commands is executed in order, and the commands within each group are by default\nexecuted in serial (synchronously) but can optionally be executed in parallel (asynchronously).\n\n![screenshot](screenshot.png)\n\n## A) Setup\nInstall package for node:\n```shell\n$ npm install --save-dev run-scripts-util\n```\n\n## B) Usage\n### 1. npm package.json scripts\nUse `run-scripts` in the `\"scripts\"` section of your **package.json** file and add a\nparameter naming the key in `runScriptsConfig` holding the group (array) of commands to\nexecute.\n\nExample **package.json** scripts:\n```json\n   \"scripts\": {\n      \"build\": \"run-scripts clean compile\",\n   },\n```\n\n### 2. CLI flags\nCommand-line flags:\n| Flag                  | Description                                                     | Value      |\n| --------------------- | ----------------------------------------------------------------| ---------- |\n| `--continue-on-error` | Do not throw an exception if a task exits with an error status. | N/A        |\n| `--note`              | Place to add a comment only for humans.                         | **string** |\n| `--only`              | Execute just one command in the group (starts with 1).          | **number** |\n| `--parallel`          | Execute all commands within each group asynchronously.          | N/A        |\n| `--quiet`             | Suppress informational messages.                                | N/A        |\n| `--verbose`           | Add script group name to informational messages.                | N/A        |\n\n### 3. Example CLI usage\nExamples:\n   - `run-scripts clean compile`\u003cbr\u003e\n   Executes the `clean` group of commands and then execute the `compile` group fo commands.\n\n   - `run-scripts clean compile --quiet`\u003cbr\u003e\n   Does not display information messages.\n\n   - `run-scripts clean compile --quiet '--note=Listen to silence'`\u003cbr\u003e\n   Notes are handy for adding a short comment.\n\n   - `run-scripts compile --verbose --only=2`\u003cbr\u003e\n   Executes just the second command in the `compile` group.\n\n   - `run-scripts lint watch --parallel`\u003cbr\u003e\n   Executes all the `lint` commands in parallel and then after all the commands are finished executes\n   the `watch` commands in parallel.\n\n_**Note:** Single quotes in commands are normalized so they work cross-platform and avoid the errors often encountered on Microsoft Windows._\n\n### 4. Skip a command\nTo _comment out_ a command prepend two slashes (`//`) to the command.\n\nIn the example below, the first `tsc` command will be skipped while the `tsc --verbose` command will be executed:\n ```json\n\"runScriptsConfig\": {\n   \"compile\": [\n      \"//tsc\",\n      \"tsc --verbose\",\n      \"lessc src/web-app/style.less build/web-app/style.css\"\n   ]\n}\n```\n\n### 5. Debug a command\nTo manually run a single command, use `npx` from the terminal plus the `--only` flag.\n\nFor example, to run the third command in the `compile` group by itself:\n```shell\n$ npx run-scripts compile --only=3\n```\n\n## C) Application Code\nEven though **run-scripts-util** is primarily intended for build scripts, the package can be used programmatically in ESM and TypeScript projects.\n\nExample:\n``` typescript\nimport { runScripts } from 'run-scripts-util';\n\nconst options = { quiet: false };\nrunScripts.exec('compile', options);\nrunScripts.execParallel('watch', options);\n```\n\nSee the **TypeScript Declarations** at the top of [run-scripts.ts](src/run-scripts.ts) for documentation.\n\n\u003cbr\u003e\n\n---\n**CLI Build Tools for package.json**\n   - 🎋 [add-dist-header](https://github.com/center-key/add-dist-header):\u0026nbsp; _Prepend a one-line banner comment (with license notice) to distribution files_\n   - 📄 [copy-file-util](https://github.com/center-key/copy-file-util):\u0026nbsp; _Copy or rename a file with optional package version number_\n   - 📂 [copy-folder-util](https://github.com/center-key/copy-folder-util):\u0026nbsp; _Recursively copy files from one folder to another folder_\n   - 🪺 [recursive-exec](https://github.com/center-key/recursive-exec):\u0026nbsp; _Run a command on each file in a folder and its subfolders_\n   - 🔍 [replacer-util](https://github.com/center-key/replacer-util):\u0026nbsp; _Find and replace strings or template outputs in text files_\n   - 🔢 [rev-web-assets](https://github.com/center-key/rev-web-assets):\u0026nbsp; _Revision web asset filenames with cache busting content hash fingerprints_\n   - 🚆 [run-scripts-util](https://github.com/center-key/run-scripts-util):\u0026nbsp; _Organize npm package.json scripts into groups of easy to manage commands_\n   - 🚦 [w3c-html-validator](https://github.com/center-key/w3c-html-validator):\u0026nbsp; _Check the markup validity of HTML files using the W3C validator_\n\nFeel free to submit questions at:\u003cbr\u003e\n[github.com/center-key/run-scripts-util/issues](https://github.com/center-key/run-scripts-util/issues)\n\n[MIT License](LICENSE.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcenter-key%2Frun-scripts-util","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcenter-key%2Frun-scripts-util","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcenter-key%2Frun-scripts-util/lists"}