Gathering detailed insights and metrics for script-launcher
Gathering detailed insights and metrics for script-launcher
Gathering detailed insights and metrics for script-launcher
Gathering detailed insights and metrics for script-launcher
karma-script-launcher
A Karma plugin. Launcher for shell scripts.
@alwaysmeticulous/replay-orchestrator-launcher
Downloads the replay-orchestrator bundle script and executes it
aftereffect-script-launcher
Run jsx in Adobe After effect.
simple-webserver-script-launcher
Listen on a method//:ip:port/path and launch a script
npm install script-launcher
Typescript
Module System
Node Version
NPM Version
TypeScript (95.26%)
JavaScript (4.6%)
Shell (0.14%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
27 Stars
305 Commits
5 Forks
5 Watchers
3 Branches
6 Contributors
Updated on Oct 04, 2022
Latest Version
1.37.3
Package Id
script-launcher@1.37.3
Unpacked Size
153.88 kB
Size
30.88 kB
File Count
20
NPM Version
8.11.0
Node Version
16.15.1
Published on
Oct 21, 2022
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
5
Enhance your package.json scripts with features like: menus, functions, arrays, concurrency and many more. The features of Script Launcher are specialized in such a way, that working with Mac, Linux and Windows can be seamless experience.
Install script-launcher as a development dependency in your project.
1npm install script-launcher --save-dev
Use launch init to create a starter configuration based on one of the available templates.
1npx launch init basic
If not already done so, change your package.json start script, so it will start Script Launcher. If you do not want to change your start script, you can also add custom run scripts for starting Script Launcher.
Example: package.json
1{ 2 ... 3 "scripts": { 4 "start": "launch", 5 ... 6 }, 7 ... 8}
You are now ready to start use Script Launcher by running: npm start
or npm start serve:dev
.
1npm start
You can also show the menu by running: npx launch
1✔ Select action › serve 2✔ Select environment › acc 3✔ Are you sure … yes 4 5Executing: npm start serve:acc 6 7Serve acc command.
1npm start serve:dev 2npm start build:production
Basically you can now use npm start
instead of npm run
.
1Serve dev command. 2Build production command.
1npx launch list
1build:acc 2build:dev 3build:production 4serve:acc 5serve:dev 6serve:production
npm run
For a cusom run script to work, you have to add a script to your package.json file, make sure there is a similar named script in your launcher-config.json file.
Example: package.json
1{ 2 ... 3 "scripts": { 4 "lint": "launch", 5 "test": "launch", 6 ... 7 }, 8 ... 9}
Example: launcher-config.json
1{ 2 "scripts": { 3 "lint": "echo Linting code...", 4 "test": "echo Testing code..." 5 } 6}
Example run commands
1npm run lint 2npm run test
Make sure all your repository changes are fully committed so you can undo the changes easily if they do not suit your needs. Remove or rename the start script in your package.json file.
Now your are ready to migrate your package.json scripts to launcher-config.json scripts. By executing the command:
1npx launch migrate
Migrate using parameter migration option:
1npx launch migrate --params
In a traditional package.json you can only run scripts on a per line basis. With larger projects that have multiple environments, this can quickly become a hassle and difficult to maintain, like the example below:
1// Traditional package.json scripts // 2{ 3 "scripts": { 4 "build:uva:dev": "ng build uva -c=dev --prod", 5 "build:uva:tst": "ng build uva -c=tst --prod", 6 "build:uva:acc": "ng build uva -c=acc --prod", 7 "build:uva:prd": "ng build uva -c=prd --prod", 8 "build:hva:dev": "ng build hva -c=dev --prod", 9 "build:hva:tst": "ng build hva -c=tst --prod", 10 "build:hva:acc": "ng build hva -c=acc --prod", 11 "build:hva:prd": "ng build hva -c=prd --prod", 12 "deploy:uva:dev": "npm run build:uva:dev && firebase deploy --public dist/uva --project status-uva-dev", 13 "deploy:uva:tst": "npm run build:uva:tst && firebase deploy --public dist/uva --project status-uva-tst", 14 "deploy:uva:acc": "npm run build:uva:acc && firebase deploy --public dist/uva --project status-uva-acc", 15 "deploy:uva:prd": "npm run build:uva:prd && firebase deploy --public dist/uva --project status-uva-prd", 16 "deploy:hva:dev": "npm run build:hva:dev && firebase deploy --public dist/hva --project status-hva-dev", 17 "deploy:hva:tst": "npm run build:hva:tst && firebase deploy --public dist/hva --project status-hva-tst", 18 "deploy:hva:acc": "npm run build:hva:acc && firebase deploy --public dist/hva --project status-hva-acc", 19 "deploy:hva:prd": "npm run build:hva:prd && firebase deploy --public dist/hva --project status-hva-prd", 20 "deploy:dev": "npm run deploy:uva:dev && npm run deploy:hva:dev", 21 "deploy:tst": "npm run deploy:uva:tst && npm run deploy:hva:tst", 22 "deploy:acc": "npm run deploy:uva:acc && npm run deploy:hva:acc", 23 "deploy:prd": "npm run deploy:uva:prd && npm run deploy:hva:prd" 24 } 25}
With script-launcher you have the benefits of using variables, script references and many more features, so you can make the above example easier to maintain:
1// Example when using the Script Launcher migrate command: 2// npx launch migrate --params 3{ 4 "scripts": { 5 "build:$project:$config": "ng build $project -c=$config --prod", 6 "deploy:$project:$config": [ 7 "build:$project:$config", 8 "firebase deploy --public dist/$project --project status-$project-$config" 9 ], 10 "deploy:$config": [ 11 "deploy:uva:$config", 12 "deploy:hva:$config" 13 ] 14 } 15}
To start this example you would use: npm start build:uva:tst
, npm start deploy:prd
etc.
It's also possible to extend the example with an interactive menu, so a new developer can get start on your project more easily:
1{ 2 "menu": { 3 "description": "deploy organization", 4 "uva:University of Amsterdam.": { 5 "description": "deploy environment", 6 "acceptance": "deploy:uva:acc", 7 "production": "deploy:uva:tst" 8 }, 9 "hva:Amsterdam University of Applied Sciences.": { 10 "description": "deploy environment", 11 "acceptance": "deploy:hva:acc", 12 "production": "deploy:hva:tst" 13 } 14 }, 15 "options": { 16 "menu": { 17 "defaultChoice": "hva:acc" 18 } 19 } 20}
You would use: npm start
to start the menu.
To test an example, copy the json content from the example to the file named launcher-config.json and run the script.
This example uses square brackets to start multiple script one by one. This feature will make long script lines more readable.
Create file: launcher-config.json
1{ 2 "scripts": { 3 "build-stuff": [ 4 "echo Build step 1", 5 "echo Build step 2", 6 "echo Build step 3" 7 ] 8 } 9}
Run: npm start build-stuff
1Build step 1 2Build step 2 3Build step 3
Specify an existing directory as an script command and it will change to that directory for the next scripts it executes. This can be handy if your script have to be run from within a different location.
Create file: launcher-config.json
1{ 2 "scripts": { 3 "build-stuff": [ 4 "node_modules/script-launcher", 5 "echo *.js" 6 ] 7 } 8}
Run: npm start build-stuff
1common.js config-loader.js executor.js launch-menu.js launch.js logger.js scripts.js spawn-process.js variables.js
Use the dollar-sign in the script id and command, to specify script function parameter. You can specify a default value by using the equal sign. This feature makes it possible to start one script with different parameters.
Create file: launcher-config.json
1{ 2 "scripts": { 3 "serve:$project=uva:$config=dev": "echo ng serve $project -c=$config" 4 } 5}
Run: npm start serve
, npm start serve::tst
or npm start serve:hva:prd
etc.
1ng serve uva -c=dev
1ng serve uva -c=tst
1ng serve hva -c=prd
Use an existing script id in the command section to execute another script in your config file. This feature makes it possible to reuse scripts from another script, with different arguments if desired.
Create file: launcher-config.json
1{ 2 "scripts": { 3 "build:$project:$config": "echo ng build $project -c=$config", 4 "deploy:$project:$config": [ 5 "build:$project:$config", 6 "echo firebase deploy --public dist/$project -P $project-$config" 7 ], 8 "deploy:$config": [ 9 "deploy:uva:$config", 10 "deploy:hva:$config" 11 ] 12 } 13}
Run: npm start deploy:tst
1ng build uva -c=tst 2firebase deploy --public dist/uva -P uva-tst 3ng build hva -c=tst 4firebase deploy --public dist/hva -P hva-tst
Use wildcards '*' to select multiple scripts. Wildcards cannot be used for selecting function by there parameters, this will result in a parameter containing the wildcard..
Create file: launcher-config.json
1{ 2 "scripts": { 3 "build:css": "echo Building: .css files", 4 "build:js": "echo Building: .js files", 5 "build:html": "echo Building: .html files", 6 "build:all": { 7 "concurrent": [ 8 "build:*" 9 ] 10 } 11 } 12}
Run: npm start build:*
, npm start build:all
or npx launch --concurrent build:*
1Building: .css files 2Building: .js files 3Building: .html files
Use the dollar-sign in the script command, to references command line arguments and environment variables on Linux, Mac and windows in a consistent manner. It is also possible to set environment variables and use aliases.
For compatibility reasons: when using a script id that is equal to the command being executed, all arguments are appended automatically.
Create file: launcher-config.json
1{ 2 "scripts": { 3 "build-stuff": [ 4 "environment=my-env", 5 "package=$npm_package", 6 "echo Package version: $package_version", 7 "echo Package version: $npm_package_version", 8 "echo Argument 1 : $1", 9 "echo Argument 2 : $2", 10 "echo", 11 "echo All arguments: $*", 12 "echo Offset arguments: $2*", 13 "echo Environment : $environment" 14 ], 15 "echo": "echo" 16 } 17}
In this example node will be an alias for $npm_config_node. So $node_version corresponds to $npm_config_node_version
Run: npm start build-stuff arg1 arg2 arg3
or npm start echo arg1 arg2 arg3
1Package version: 1.37.3 2Package version: 1.37.3 3Argument 1 : arg1 4Argument 2 : arg2 5All arguments: arg1 arg2 arg3 6Offset arguments: arg2 arg3 7Environment : my-env
1arg1 arg2 arg3
Pattern | Description |
---|---|
${var:num1:num2} | Substring |
${var/pattern/string} | Find and replace (only replace first occurrence) |
${var//pattern/string} | Find and replace all occurrences |
${var,} | Convert first character to lowercase. |
${var,,} | Convert all characters to lowercase. |
${var^} | Convert first character to uppercase. |
${var^^} | Convert all character to uppercase.. |
Create file: launcher-config.json
1{ 2 "scripts": { 3 "build-stuff": [ 4 "var=app-uva=hva-prd", 5 "echo ${var::-8}", 6 "echo ${var:8}", 7 "echo ${var:4:7}", 8 "echo ${var/-/=}", 9 "echo ${var//-/=}", 10 "echo ${var^^}", 11 "echo ${var^}", 12 "var=APP-UVA=HVA-PRD", 13 "echo ${var,,}", 14 "echo ${var,}", 15 "echo ${*^^}", 16 "echo ${2*,}" 17 ] 18 } 19}
Run: npm start build-stuff arg1 ARG2 arg3
1app-uva 2hva-prd 3uva=hva 4app=uva=hva-prd 5app=uva=hva=prd 6APP-UVA=HVA-PRD 7App-uva=hva-prd 8app-uva=hva-prd 9aPP-UVA=HVA-PRD 10ARG1 ARG2 ARG3 11aRG2 arg3
laucher
directly, for example: launch init
or launch version
npm start build my-arg1 my-arg2
$1
$project
Create file: launcher-config.json
1{ 2 "scripts": { 3 "myFunc:$funcParam1:$funcParam2": [ 4 "echo Function Parameter 1: $funcParam1", 5 "echo Function Parameter 2: $funcParam2", 6 "echo Function Arguments 1: $1", 7 "echo Function Arguments 2: $2", 8 "echo Function All arguments: $*" 9 ], 10 "build-stuff:$myParam1:$myParam2": [ 11 "--", 12 "echo Main Parameter 1: $myParam1", 13 "echo Main Parameter 2: ${myParam2}", 14 "echo Main Arguments 1: $1", 15 "echo Main Arguments 2: $2", 16 "echo Main All arguments: $*", 17 "echo Main Offset arguments: $2*", 18 "--", 19 "myFunc:$myParam1:funcParam funcArg $1", 20 "--" 21 ] 22 } 23}
Run: npm start build-stuff:param1:param2 arg1 arg2 arg3
1-------------------------------- 2Main Parameter 1: param1 3Main Parameter 2: param2 4Main Arguments 1: arg1 5Main Arguments 2: arg2 6Main All arguments: arg1 arg2 arg3 7Main Offset arguments: arg2 arg3 8-------------------------------- 9Function Parameter 1: param1 10Function Parameter 2: funcParam 11Function Arguments 1: funcArg 12Function Arguments 2: arg1 13Function All arguments: funcArg arg1 14--------------------------------
Use a backslash in the script command, to escaping variables.
Create file: launcher-config.json
1{ 2 "scripts": { 3 "escaping": [ 4 "echo '\\$1 ' : '$1'", 5 "echo '\\$npm_package_version ' : '$npm_package_version'", 6 "echo '\\${1} ' : '${1}'", 7 "echo '\\${npm_package_version}' : '${npm_package_version}'" 8 ] 9 } 10}
Run: npm start escaping arg1
1$1 : arg1 2$npm_package_version : 1.37.3 3${1} : arg1 4${npm_package_version} : 1.37.3
Pattern | Type | Description |
---|---|---|
launch_version | Environment | Launcher Version number |
launch_platform | Environment | Operating system platform |
launch_time_start | Environment | Start time |
launch_time_current | Environment | Current time |
launch_time_elapsed | Environment | Elapsed time |
launch_style_blue | Environment | Blue text |
launch_style_bold | Environment | Bold text |
launch_style_cyan | Environment | Cyan text |
launch_style_dim | Environment | Dim text |
launch_style_green | Environment | Green text |
launch_style_normal | Environment | Nomal text |
launch_style_red | Environment | Red text |
launch_style_yellow | Environment | Yellow text |
"echo" | Command | Output an empty line |
"" | Command | Output an empty line |
"--" | Command | Line with the width of the terminal |
" || true" | Command | Added at the end of a command to suppress errors |
"#" | Command | Added at the begining for a line to disable execution |
"|?" | Command | Grep like functionality |
Create file: launcher-config.json
1{ 2 "scripts": { 3 "build-stuff": { 4 "condition": "echo grep example |? example", 5 "sequential-then": [ 6 "echo ${launch_style_bold}Version:$launch_style_normal $launch_version", 7 "echo ${launch_style_bold}Platform:$launch_style_normal $launch_platform", 8 "echo ${launch_style_bold}Time:$launch_style_normal $launch_time_start", 9 "--", 10 "echo Color: ${launch_style_blue}Blue$launch_style_normal", 11 "echo Color: ${launch_style_bold}Bold$launch_style_normal", 12 "echo", 13 "echo Color: ${launch_style_cyan}Cyan$launch_style_normal", 14 "echo Color: ${launch_style_dim}Dim$launch_style_normal", 15 "", 16 "# The error of the next action will be suppressed", 17 "exit 1 || true", 18 "echo Color: ${launch_style_green}Green$launch_style_normal", 19 "echo Color: ${launch_style_red}Red$launch_style_normal", 20 "echo Color: ${launch_style_yellow}Yellow$launch_style_normal", 21 "--", 22 "echo ${launch_style_bold}Current:$launch_style_normal $launch_time_current", 23 "echo ${launch_style_bold}Elapsed:$launch_style_normal $launch_time_elapsed" 24 ] 25 } 26 } 27}
Run: npm start build-stuff
1grep example 2Version: 1.37.3 3Platform: linux 4Time: 2019-09-16 10:33:20.628 5-------------------------------- 6Color: Blue 7Color: Bold 8Color: Cyan 9Color: Dim 10 11Color: Green 12Color: Red 13Color: Yellow 14-------------------------------- 15Current: 2019-09-16 10:33:42.285 16Elapsed: 137ms
Script Launcher makes use of the Glob package, so you can use any of the supported glob patterns in your scripts.
Create file: launcher-config.json
1{ 2 "scripts": { 3 "build-stuff": [ 4 "node_modules/script-launcher", 5 "echo Javascript files files: *.js", 6 "echo Markdown files: **/*.md" 7 ] 8 } 9}
Run: npm start build-stuff
1Javascript files files: common.js config-loader.js executor.js launch-menu.js launch.js logger.js scripts.js spawn-process.js variables.js 2Markdown files: README.md
This example uses the concurrent keyword to run multiple script in parallel and the sequential keyword to start multiple script one by one. This feature is convenient in a development environment, when you want to start development server in the background.
Use the limit
argument or option to limit the number of commands to execute in parallel..
Create file: launcher-config.json
1{ 2 "scripts": { 3 "sleep:$time": "node -e \"setTimeout(() => {}, $time)\"", 4 "background:$job:$time": [ 5 "echo Background job : $job", 6 "sleep:$time", 7 "echo Completed job : $job" 8 ], 9 "build-stuff": { 10 "concurrent": [ 11 "background:1:3000", 12 "background:2:5000" 13 ], 14 "sequential": [ 15 "echo Sequential job : 3", 16 "sleep:1000", 17 "echo Sequential job : 4", 18 "sleep:1000" 19 ] 20 } 21 } 22}
Run: npm start build-stuff
1Background job : 1 2Background job : 2 3Sequential job : 3 4Sequential job : 4 5Completed job : 1 6Completed job : 2
This example uses the inline script blocks to run multiple script in parallel and to run multiple script one by one.
Create file: launcher-config.json
1{ 2 "scripts": { 3 "sleep:$time": "node -e \"setTimeout(() => {}, $time)\"", 4 "background:$job:$time": [ 5 "echo Background job : $job", 6 "sleep:$time", 7 "echo Completed job : $job" 8 ], 9 "build-stuff": [ 10 [ 11 "background:1:3000", 12 "background:2:5000" 13 ], 14 { 15 "sequential": [ 16 "echo Sequential job : 3", 17 "sleep:1000", 18 "echo Sequential job : 4", 19 "sleep:1000" 20 ] 21 } 22 ] 23 } 24}
Run: npm start build-stuff
1Background job : 1 2Background job : 2 3Completed job : 1 4Completed job : 2 5Sequential job : 3 6Sequential job : 4
Confirmation prompts can be used for asking a confirmation to continue. Use the confirm argument to auto confirm.
Create file: launcher-config.json
1{ 2 "scripts": { 3 "build-stuff": { 4 "confirm": "Are you sure you want to continue", 5 "sequential-then": "echo You are sure!", 6 "sequential-else": "echo You are not sure!" 7 } 8 } 9}
Run: npm start build-stuff
, npx launch build-stuff confirm
or npx launch build-stuff --confirm=false
1✔ Are you sure you want to continue ... yes 2You are sure!
1✔ Are you sure you want to continue ... yes 2You are sure!
1✔ Are you sure you want to continue ... no 2You are not sure!
The value of the condition and exclusion statement can be a string or an array of strings containing a JavaScript expression returning a Boolean, directory name or a shell command.
Create file: launcher-config.json
1{ 2 "scripts": { 3 "build-stuff": [ 4 { 5 "exclusion": "node_modules_test", 6 "sequential-then": [ 7 "echo npm install", 8 "mkdir node_modules_test" 9 ] 10 }, 11 { 12 "condition": "node_modules_test", 13 "sequential-then": [ 14 "echo npm start", 15 { 16 "condition": "'$launch_platform'==='win32'", 17 "sequential": "echo Test platform type.", 18 "sequential-then": "rmdir node_modules_test", 19 "sequential-else": "rm -d node_modules_test" 20 } 21 ] 22 } 23 ] 24 }, 25 "options": { 26 "logLevel": 2 27 } 28}
Run: npm start build-stuff
1/bin/sh: 1: node_modules_test: not found 2npm install 3npm start 4Test platform type.
The repeater statement must contain a reference to a settings array. The corresponding script block will be executed for each instance in the settings array.
Example using a string array. Create file: launcher-config.json
1{ 2 "scripts": { 3 "ping": [ 4 { 5 "repeater": "$launch_setting_servers", 6 "sequential": [ 7 "echo Action: $launch_setting_command $_" 8 ] 9 } 10 ] 11 }, 12 "settings": { 13 "command": "ping", 14 "servers": [ 15 "www.google.com", 16 "duckduckgo.com", 17 "bing.com" 18 ] 19 } 20}
Run: npm start ping
1Action: ping www.google.com 2Action: ping duckduckgo.com 3Action: ping bing.com
Example using an object array. Create file: launcher-config.json
1{ 2 "scripts": { 3 "ping": [ 4 { 5 "repeater": "$launch_setting_servers", 6 "sequential": [ 7 "echo $_name", 8 "--", 9 "echo Action: $launch_setting_command $_host", 10 "" 11 ] 12 } 13 ] 14 }, 15 "settings": { 16 "command": "ping", 17 "servers": [ 18 { 19 "name": "Google", 20 "host": "www.google.com" 21 }, 22 { 23 "name": "DuckDuckGo", 24 "host": "duckduckgo.com" 25 }, 26 { 27 "name": "Bing", 28 "host": "bing.com" 29 } 30 ] 31 } 32}
Run: npm start ping
1Google 2-------------------------------- 3Action: ping www.google.com 4 5DuckDuckGo 6-------------------------------- 7Action: ping duckduckgo.com 8 9Bing 10-------------------------------- 11Action: ping bing.com 12
Use the menu section to create an interactive landing menu, so a new developer can get start on your project more easily.
The options.menu.timeout can be used to auto close the menu after a specified time. Use the Menu options section for more information on all the available options.
Create file: launcher-config.json
1{ 2 "scripts": { 3 "serve:$project:dev": { 4 "concurrent": [ 5 "echo Start development server", 6 "echo ng serve $project -c=dev" 7 ] 8 }, 9 "serve:$project:$config": "echo ng serve $project -c=$config" 10 }, 11 "menu": { 12 "description": "organization", 13 "uva:University of Amsterdam.": { 14 "description": "environment", 15 "development": "serve:uva:dev", 16 "acceptance": "serve:uva:acc", 17 "production": "serve:uva:prd" 18 }, 19 "hva:Amsterdam University of Applied Sciences.": { 20 "description": "environment", 21 "development:Builds and serves your app for development.": "serve:hva:dev", 22 "acceptance:Builds and serves your app for acceptance.": "serve:hva:acc", 23 "production:Builds and serves your app for production.": "serve:hva:prd" 24 } 25 }, 26 "options": { 27 "menu": { 28 "defaultChoice": "hva:development" 29 } 30 } 31}
Run: npm start menu uva:acceptance
, npm start menu
or npm start
1? Select organization › - Use arrow-keys. Return to submit. 2❯ uva - University of Amsterdam. 3 hva 4 5✔ Select organization › uva 6? Select environment › - Use arrow-keys. Return to submit. 7 development 8❯ acceptance 9 production 10 11✔ Select environment › acceptance 12 13Executing: npm start serve:uva:acc 14 15ng serve uva -c=acc
1? Select organization › - Use arrow-keys. Return to submit. 2 uva 3❯ hva - Amsterdam University of Applied Sciences. 4 5✔ Select organization › hva 6 7Executing: npm start serve:hva:dev 8 9Start development server 10ng serve hva -c=dev
Use the menu section options to specify a defaultScript, this will disable the interactive menu.
Best practices is to specify the menu default options in the launcher-custom.json file, and add this file the your .gitignore. Now every developer can customize its menu without interfering with the project defaults.
Use npm start menu
to ignore the defaultScript option, so the menu will be interactive.
Create file: launcher-config.json
1{ 2 "scripts": { 3 "serve:$environment": "echo Serve script: $environment", 4 "build:$environment": "echo Build script: $environment" 5 }, 6 "menu": { 7 "description": "organization", 8 "uva:University of Amsterdam.": { 9 "description": "environment", 10 "serve": "serve:uva", 11 "build": "build:uva" 12 }, 13 "hva:Amsterdam University of Applied Sciences.": { 14 "description": "environment", 15 "serve": "serve:hva", 16 "build": "build:hva" 17 } 18 }, 19 "options": { 20 "menu": { 21 "defaultScript": "build:hva" 22 } 23 } 24}
Run: npm start
1Auto menu: (Use the menu by running: npm start menu) 2Executing: npm start build:hva 3 4Build script: hva
Use the help for a list of available options.
Run: npx launch --help
1Usage: launch [command] [options...] 2 3Commands: 4 init [template] Create starter config files. 5 list [type] List available launcher scripts. 6 migrate Migrate your package.json scripts. 7 help Show this help. 8 version Outputs launcher version. 9 10Options: 11 logLevel= Set log level. 12 dry= Do not execute commands. 13 config= Merge in an extra config file. 14 confirm= Auto value for confirm conditions. 15 ansi= Enable or disable ansi color output. 16 directory= The directory from which configuration files are loaded. 17 menuTimeout= Set menu timeout in seconds. 18 params= Set the number of parameters to preserve. 19 concurrent= Execute commandline wildcard matches in parallel. 20 limit= Limit the number of commands to execute in parallel.
Run: npx launch build:css build:js --dry
this will execute a dry run on the build:css and build:js script
1Loaded config: launcher-config.json 2 3Date : 2019-09-16 10:33:20.628 4Version : 1.37.3 5Lifecycle event : undefined 6Launch script : [ 'build:css', 'build:js' ] 7Launch arguments : [ '--directory=./tests/temp/0052', 'build:css', 'build:js', '--dry' ] 8 9Script id : build:css 10Circular : false 11Script params : {} 12Script args : [ 'build:css' ] 13 14Dry Command : 'echo Building: .css files ' 15Dry Command : 'echo Building: .js files ' 16 17ExitCode: 0 18Elapsed: 237ms
Use the init command to create a starter configuration for you project.
Run: npx launch init
this will list the available templates
1Available templates: 2 3angular 4basic 5blank 6 7Example usage: npx launch init basic
Run: npx launch init basic
this will create a basic starter configuration
1Create starter config: basic 2 3Creating: launcher-config.json 4Creating: launcher-menu.json 5 6Updating package.json. 7 8Start script of package.json updated.
Use the migrate command to convert your package.json script to a script-launcher configuration. Use the params option the parameterize your script functions.
Run: npx launch migrate --params=1
this will convert your package.json scripts
1Migrating: package.json 2 3Script to migrate: 12 4Script to update: 2 5 6✔ Are you sure ... yes 7 8Updating: package.json 9Creating: launcher-menu.json 10Creating: launcher-config.json
Start one or more script directly from the command line sequentially or concurrently
Run: npx launch build:css build:js
to start one or more script in sequence
1Building: .css files 2Building: .js files
Run: npx launch build:css build:js --concurrent
to start one ore more script in parallel
1Building: .css files 2Building: .js files
Use the list command to display the available scripts. This can be used for enabling tab completion.
Run: npx launch list complete
for listing scripts that can be used for tab completion. This is the default value.
1serve:hva:acc 2serve:hva:dev 3serve:hva:prd 4serve:uva:acc 5serve:uva:dev 6serve:uva:prd
Run: npx launch list script
for listing available scripts.
1serve:$project:$config 2serve:$project:dev
Run: npx launch list menu
for listing available menu scripts.
1serve:hva:acc 2serve:hva:dev 3serve:hva:prd 4serve:uva:acc 5serve:uva:dev 6serve:uva:prd
The launcher settings can be used to specify named values that can be used by the launcher scripts. Consult the repeaters implementation examples section for more information on repeaters.
Create file: launcher-config.json
1{ 2 "scripts": { 3 "build:$config": [ 4 "settings=$launch_setting_${config}", 5 "echo name: $launch_setting_name", 6 "echo version: $settings_version", 7 "echo ng build -c=$config --deploy-url $settings_url", 8 "", 9 { 10 "repeater": "$launch_setting_${config}_server", 11 "sequential": [ 12 "echo Deploying to: $_" 13 ] 14 } 15 ] 16 }, 17 "settings": { 18 "name": "example", 19 "dev": { 20 "version": "2.0.0", 21 "url": "$launch_setting_name.dev.com", 22 "server": [ 23 "server1.dev.com", 24 "server2.dev.com" 25 ] 26 }, 27 "acc": { 28 "version": "1.9.0", 29 "url": "$launch_setting_name.acc.com", 30 "server": [ 31 "server1.acc.com", 32 "server2.acc.com" 33 ] 34 }, 35 "production": { 36 "version": "1.8.0", 37 "url": "$launch_setting_name.prd.com", 38 "server": [ 39 "server1.prd.com", 40 "server2.prd.com" 41 ] 42 } 43 } 44}
Run: npm start build:dev
, npm start build:acc
or npm start build:production
1name: example 2version: 2.0.0 3ng build -c=dev --deploy-url example.dev.com 4 5Deploying to: server1.dev.com 6Deploying to: server2.dev.com
1name: example 2version: 1.9.0 3ng build -c=acc --deploy-url example.acc.com 4 5Deploying to: server1.acc.com 6Deploying to: server2.acc.com
1name: example 2version: 1.8.0 3ng build -c=production --deploy-url example.prd.com 4 5Deploying to: server1.prd.com 6Deploying to: server2.prd.com
The launcher options can be used the customize the default behavior of Script Launcher.
The files options can be used to configure the config files to load when starting launcher. When using multiple files they will be merged together in the loading order. Be aware the launcher-config.json
is always the first file being loaded even when it is not present in the files list.
By using this option it's possible the split your configuration over multiple files. It's a good practice is to split your script and menu configurations to their own file. You could also include the package.json
file in this list, then you can use the strength of Script Launcher in your package.json
file.
The default value of this list is presented in the following example:
1{ 2 "scripts": { 3 ... 4 }, 5 "options": { 6 "files": [ 7 "launcher-config.json", 8 "launcher-scripts.json", 9 "launcher-settings.json", 10 "launcher-menu.json", 11 "launcher-custom.json", 12 ] 13 } 14}
The script shell options can be used to configure the spawn shell, this value is passed to the options shell of the node child_process.spawn method. If you want to specify a shell for a specific platform, use one of the platform names as a nested object name. If there is no platform name match found the default will be used.
Example shell option for specific platform
1{ 2 "scripts": { 3 ... 4 }, 5 "options": { 6 "script": { 7 "shell": { 8 "aix":"bash", 9 "darwin":"bash", 10 "freebsd":"bash", 11 "linux":"bash", 12 "openbsd":"bash", 13 "sunos":"bash", 14 "win32":"cmd.exe", 15 "default":"bash" 16 } 17 } 18 } 19}
The default value is presented in the following example:
1{ 2 "scripts": { 3 ... 4 }, 5 "options": { 6 "script": { 7 "shell": true 8 } 9 } 10}
Official documentation of the fast-glob
options
If the nonull script-launcher option is set, and no match was found, then the match contains the original pattern.
1{ 2 "options": { 3 "glob": { 4 "nonull": false 5 } 6 } 7}
The default value is presented in the following example:
1{ 2 "scripts": { 3 ... 4 }, 5 "options": { 6 "menu": { 7 "defaultChoice": "", 8 "defaultSelect": "", 9 "defaultScript": "", 10 "timeout": 0, 11 "confirm" :true 12 } 13 } 14}
The logLevel option is used for configuring the Script Launcher log level, available values are: 0=disabled 1=info 2=log 3=debug
The default value is presented in the following example:
1{ 2 "scripts": { 3 ... 4 }, 5 "options": { 6 "logLevel": 0 7 } 8}
Use the limit option to limit the number of commands to execute in parallel. When using the value 0 the number of available cpus will be used.
The default value is presented in the following example:
1{ 2 "scripts": { 3 ... 4 }, 5 "options": { 6 "limit": 0 7 } 8}
Use the dry option to prevent the execution of the scripts.
The default value is presented in the following example:
1{ 2 "scripts": { 3 ... 4 }, 5 "options": { 6 "dry": false 7 } 8}
To enable tab completion for script-launcher in your current terminal, execute the following commands. This will test if you are using tab completion on npm start
if so, it will execute npx launch list completion
if not, it will execute the default npm completion function _npm_completion
.
1eval "$(npm completion)" 2 3_launch_completion () { 4 if [[ $COMP_LINE != "npm start"* ]] ; then 5 _npm_completion 6 else 7 npx --quiet --no-install launch list 8 fi 9} 10complete -o default -F _launch_completion npm
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 4/26 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
11 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More