Socket
Socket
Sign inDemoInstall

script-launcher

Package Overview
Dependencies
30
Maintainers
1
Versions
131
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.26.0 to 1.26.1

114

launch.js

@@ -623,3 +623,3 @@ "use strict";

],
list: ' ' + common_1.Colors.Cyan + 'list ' + common_1.Colors.Normal + 'List available launcher scripts.',
list: ' ' + common_1.Colors.Cyan + 'list ' + common_1.Colors.Normal + '[type] List available launcher scripts.',
migrate: ' ' + common_1.Colors.Cyan + 'migrate ' + common_1.Colors.Normal + 'Migrate your package.json scripts.',

@@ -739,15 +739,44 @@ help: ' ' + common_1.Colors.Cyan + 'help ' + common_1.Colors.Normal + 'Show this help.',

}
function getMenuScripts(menu, result) {
var e_19, _a;
if (result === void 0) { result = []; }
try {
for (var _b = __values(Object.entries(menu)), _c = _b.next(); !_c.done; _c = _b.next()) {
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
if (key === 'description')
continue;
if (key === 'separator')
continue;
if (typeof value === 'string') {
if (value.includes(' '))
continue;
result.push(value);
}
else {
getMenuScripts(value, result);
}
}
}
catch (e_19_1) { e_19 = { error: e_19_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_19) throw e_19.error; }
}
return result;
}
function main(lifecycleEvent, processArgv, npmConfigArgv, testmode) {
if (testmode === void 0) { testmode = false; }
return __awaiter(this, void 0, void 0, function () {
var exitCode, startTime, commandArgs, argsString, launchArgs, configLoad, config, interactive, fileName, shell, settings, environment, launchScript, scriptId, template, _a, _b, item, scripts, result, scriptInfo, executor, error_1, message, timespan;
var e_19, _c, _d;
return __generator(this, function (_e) {
switch (_e.label) {
var exitCode, startTime, commandArgs, argsString, launchArgs, configLoad, config, interactive, fileName, shell, settings, environment, launchScript, scriptId, template, _a, _b, item, _c, _d, item, scripts_4, menu, choices, choices_1, choices_1_1, item, scripts, result, scriptInfo, executor, error_1, message, timespan;
var e_20, _e, e_21, _f, e_22, _g, _h;
return __generator(this, function (_j) {
switch (_j.label) {
case 0:
exitCode = 1;
startTime = process.hrtime();
_e.label = 1;
_j.label = 1;
case 1:
_e.trys.push([1, 7, 8, 9]);
_j.trys.push([1, 7, 8, 9]);
commandArgs = npmConfigArgv ? JSON.parse(npmConfigArgv).remain : [];

@@ -858,16 +887,57 @@ argsString = processArgv.slice(2, processArgv.length - commandArgs.length);

if (launchArgs.arguments.list) {
try {
for (_a = __values(Object.keys(configLoad.config.scripts.scripts)), _b = _a.next(); !_b.done; _b = _a.next()) {
item = _b.value;
console.log(item);
if (launchArgs.optionals.length === 0 || launchArgs.optionals[0] === 'script') {
try {
for (_a = __values(Object.keys(configLoad.config.scripts.scripts)), _b = _a.next(); !_b.done; _b = _a.next()) {
item = _b.value;
console.log(item);
}
}
catch (e_20_1) { e_20 = { error: e_20_1 }; }
finally {
try {
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
}
finally { if (e_20) throw e_20.error; }
}
return [2 /*return*/];
}
catch (e_19_1) { e_19 = { error: e_19_1 }; }
finally {
if (launchArgs.optionals[0] === 'menu') {
try {
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
for (_c = __values(getMenuScripts(configLoad.config.menu)), _d = _c.next(); !_d.done; _d = _c.next()) {
item = _d.value;
console.log(item);
}
}
finally { if (e_19) throw e_19.error; }
catch (e_21_1) { e_21 = { error: e_21_1 }; }
finally {
try {
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
}
finally { if (e_21) throw e_21.error; }
}
return [2 /*return*/];
}
return [2 /*return*/];
if (launchArgs.optionals[0] === 'completion') {
scripts_4 = Object.keys(configLoad.config.scripts.scripts).filter(function (item) { return !item.includes('$'); });
menu = getMenuScripts(configLoad.config.menu).filter(function (item) { return !scripts_4.includes(item); });
choices = __spread(menu, scripts_4).sort();
try {
for (choices_1 = __values(choices), choices_1_1 = choices_1.next(); !choices_1_1.done; choices_1_1 = choices_1.next()) {
item = choices_1_1.value;
console.log(item);
}
}
catch (e_22_1) { e_22 = { error: e_22_1 }; }
finally {
try {
if (choices_1_1 && !choices_1_1.done && (_g = choices_1.return)) _g.call(choices_1);
}
finally { if (e_22) throw e_22.error; }
}
return [2 /*return*/];
}
console.error('List option not supported: ' + launchArgs.optionals);
console.error();
console.error('Use: script, menu or completion');
throw new Error();
}

@@ -877,3 +947,3 @@ if (!launchArgs.arguments.migrate) return [3 /*break*/, 3];

case 2:
_e.sent();
_j.sent();
logger_1.Logger.log();

@@ -886,3 +956,3 @@ exitCode = 0;

commandArgs.unshift(scriptId);
scripts = (_d = config.scripts).find.apply(_d, __spread(launchScript));
scripts = (_h = config.scripts).find.apply(_h, __spread(launchScript));
if (launchScript[0] === 'menu' && scripts.length === 0) {

@@ -896,3 +966,3 @@ interactive = true;

case 4:
result = _e.sent();
result = _j.sent();
startTime = result.startTime;

@@ -924,10 +994,10 @@ exitCode = result.exitCode;

case 6:
exitCode = _e.sent();
exitCode = _j.sent();
return [3 /*break*/, 9];
case 7:
error_1 = _e.sent();
error_1 = _j.sent();
message = "" + error_1;
if (error_1.message)
message = error_1.message;
if (message !== 'false')
if (message !== 'false' && message !== 'Error')
logger_1.Logger.error(message);

@@ -934,0 +1004,0 @@ return [3 /*break*/, 9];

2

package.json
{
"name": "script-launcher",
"version": "1.26.0",
"version": "1.26.1",
"description": "Enhance your package.json scripts with features like: menus, functions, arrays, concurrency and many more.",

@@ -5,0 +5,0 @@ "main": "launch.js",

@@ -44,2 +44,3 @@ [![npm version](https://badge.fury.io/js/script-launcher.svg)](https://www.npmjs.com/package/script-launcher)

* [Launcher Command: script](#launcher-command-script)
* [Launcher Command: list](#launcher-command-list)
* [Launcher settings](#launcher-settings)

@@ -52,2 +53,3 @@ * [Launcher options](#launcher-options)

* [Logging](#logging)
* [Enable tab completion](#enable-tab-completion)

@@ -676,3 +678,3 @@ ## Installation

init [template] Create starter config files.
list List available launcher scripts.
list [type] List available launcher scripts.
migrate Migrate your package.json scripts.

@@ -751,4 +753,31 @@ help Show this help.

### Launcher Command: list
Use the **list** command to display the available scripts. This can be used for [enabling tab completion](#enable-tab-completion).
**Run**: `npx launch list`
``` bash
serve:$project:dev
serve:$project:$config
```
**Run**: `npx launch list menu`
``` bash
serve:uva:dev
serve:uva:acc
serve:uva:prd
serve:hva:dev
serve:hva:acc
serve:hva:prd
```
**Run**: `npx launch list completion`
``` bash
serve:hva:acc
serve:hva:dev
serve:hva:prd
serve:uva:acc
serve:uva:dev
serve:uva:prd
```
## Launcher settings

@@ -919,1 +948,16 @@ The launcher settings can be used to specify named values that can be used by the launcher scripts. Consult the [repeaters](#repeaters) implementation examples section for more information on repeaters.

```
### Enable tab completion
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`.
``` bash
eval "$(npm completion)"
_launch_completion () {
if [[ $COMP_LINE != "npm start"* ]] ; then
_npm_completion
else
npx --quiet --no-install launch list completion
fi
}
complete -o default -F _launch_completion npm
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc