Comparing version 1.4.0 to 1.5.0
export {}; |
@@ -11,2 +11,3 @@ "use strict"; | ||
.option("-e, --allowErrors", "Allow errors (at default we stop when there is one). NOTE: always true when in async mode") | ||
.option("-y, --yarnWorkspaces", "Use yarn workspaces for the directories to run the command in") | ||
.option("-d, --envDirectories [environment_key]", "Environment variable that contains the directories, for example a package.json config var would be: npm_config_myVar") | ||
@@ -22,5 +23,6 @@ .option("-v, --verbose", "More verbose output") | ||
const allowErrors = commander.allowErrors === true; | ||
const async = commander.async === true; | ||
const envDirectories = commander.envDirectories || ""; | ||
const aSynchronous = commander.async === true; | ||
const yarnWorkspaces = commander.yarnWorkspaces === true; | ||
const envVariable = commander.envDirectories || ""; | ||
const verbose = commander.verbose === true; | ||
_1.eisd(commandToExecute, directoriesToUse, allowErrors, async, envDirectories, verbose); | ||
_1.eisd({ commandToExecute, directoriesToUse, allowErrors, aSynchronous, envVariable, yarnWorkspaces, verbose }); |
@@ -0,0 +0,0 @@ export declare function startMaster(commandToExecute: string, directoriesToUse: string[], allowFailures?: boolean, aSynchronous?: boolean, verbose?: boolean): Promise<{ |
@@ -35,3 +35,4 @@ "use strict"; | ||
function startWorker() { | ||
return !!directoriesToUse.length && cluster.fork({ commandToExecute, directory: directoriesToUse.shift(), verbose: verbose.toString() }); | ||
return (!!directoriesToUse.length && | ||
cluster.fork({ commandToExecute, directory: directoriesToUse.shift(), verbose: verbose.toString() })); | ||
} | ||
@@ -38,0 +39,0 @@ } |
@@ -0,1 +1,10 @@ | ||
declare type EisdConfig = { | ||
commandToExecute: string; | ||
directoriesToUse: string[]; | ||
allowErrors?: boolean; | ||
aSynchronous?: boolean; | ||
envVariable?: string; | ||
yarnWorkspaces?: boolean; | ||
verbose?: boolean; | ||
}; | ||
/** | ||
@@ -6,2 +15,3 @@ * This is a CLI tool helps you do execute cmds per given folder. If you try to do the same | ||
*/ | ||
export declare function eisd(commandToExecute: string, directoriesToUse: string[], allowFailures?: boolean, aSynchronous?: boolean, envVariable?: string, verbose?: boolean): Promise<void>; | ||
export declare function eisd(config: EisdConfig): Promise<void>; | ||
export {}; |
@@ -13,2 +13,3 @@ "use strict"; | ||
const cluster_1 = require("./cluster"); | ||
const yarnHelpers_1 = require("./yarnHelpers"); | ||
/** | ||
@@ -19,3 +20,3 @@ * This is a CLI tool helps you do execute cmds per given folder. If you try to do the same | ||
*/ | ||
function eisd(commandToExecute, directoriesToUse, allowFailures = false, aSynchronous = false, envVariable = "", verbose = false) { | ||
function eisd(config) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -25,26 +26,30 @@ // Prevent triggering eisd twice because the cluster-worker will rerun all the code | ||
return; | ||
process.env._runnedBefore = true; | ||
if (!commandToExecute) { | ||
process.env._runnedBefore = "true"; | ||
if (!config.commandToExecute) { | ||
process.stdout.write(colors_1.red("ERROR: No command given..\n")); | ||
throw new Error("No command found."); | ||
} | ||
if (envVariable) { | ||
if (!process.env[envVariable]) { | ||
process.stdout.write(colors_1.red(`ERROR: No environment value found on "process.env.${envVariable}"..\n`)); | ||
throw new Error(`Invalid env variable given "${envVariable}".`); | ||
if (config.yarnWorkspaces) { | ||
yarnHelpers_1.checkYarnAvailability(); | ||
config.directoriesToUse.push(...yarnHelpers_1.getYarnWorkspaces()); | ||
} | ||
if (config.envVariable) { | ||
if (!process.env[config.envVariable]) { | ||
process.stdout.write(colors_1.red(`ERROR: No environment value found on "process.env.${config.envVariable}"..\n`)); | ||
throw new Error(`Invalid env variable given "${config.envVariable}".`); | ||
} | ||
const directories = process.env[envVariable].split(" "); | ||
directoriesToUse.push(...directories); | ||
const directories = process.env[config.envVariable].split(" "); | ||
config.directoriesToUse.push(...directories); | ||
} | ||
if (!directoriesToUse.length) { | ||
if (!config.directoriesToUse.length) { | ||
process.stdout.write(colors_1.red("ERROR: No directories given..\n")); | ||
throw new Error("No directories found."); | ||
} | ||
if (verbose) { | ||
console.log("Directories:", directoriesToUse); | ||
if (config.verbose) { | ||
console.log("Directories:", config.directoriesToUse); | ||
process.stdout.write("\n"); | ||
} | ||
const { directoriesSucces, directoriesFailed } = yield cluster_1.startMaster(commandToExecute, directoriesToUse, allowFailures, aSynchronous, verbose); | ||
if (verbose && directoriesSucces.length) { | ||
process.stdout.write(colors_1.green(`Done executing '${commandToExecute}' in the following directories:`)); | ||
const { directoriesSucces, directoriesFailed } = yield cluster_1.startMaster(config.commandToExecute, config.directoriesToUse, config.allowErrors, config.aSynchronous, config.verbose); | ||
if (config.verbose && directoriesSucces.length) { | ||
process.stdout.write(colors_1.green(`Done executing '${config.commandToExecute}' in the following directories:`)); | ||
process.stdout.write("\n"); | ||
@@ -56,7 +61,7 @@ process.stdout.write(directoriesSucces.join(", ")); | ||
process.stdout.write("\n"); | ||
process.stdout.write(colors_1.red(`Error(s) while executing '${commandToExecute}' in the following directories:`)); | ||
process.stdout.write(colors_1.red(`Error(s) while executing '${config.commandToExecute}' in the following directories:`)); | ||
process.stdout.write("\n"); | ||
process.stdout.write(directoriesFailed.join(", ")); | ||
process.stdout.write("\n"); | ||
if (!allowFailures) | ||
if (!config.allowErrors) | ||
process.exit(1); | ||
@@ -63,0 +68,0 @@ } |
{ | ||
"name": "eisd", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "Execute your favorite command in SubDirectories. Use it like: `eisd '[command]' [subdirs...]` (Example: `eisd 'yarn build' client server scripts`)", | ||
@@ -39,4 +39,4 @@ "main": "lib/index.js", | ||
"@types/colors": "^1.2.1", | ||
"@types/node": "^6.0.87", | ||
"@types/shelljs": "^0.8.2", | ||
"@types/node": "^8.0.0", | ||
"@types/shelljs": "^0.8.5", | ||
"prettier": "^1.13.5", | ||
@@ -43,0 +43,0 @@ "typescript": "3.2.4" |
@@ -18,3 +18,4 @@ # Execute In SubDirectories | ||
-e, --allowErrors Allow errors (at default we stop when there is one). NOTE: always true when in async mode | ||
-d, --envDirectories [environment_key] Environment variable that contains the directories, for example a package.json config car would be: npm_config_myVar | ||
-y, --yarnWorkspaces Use yarn workspaces for the directories to run the command in | ||
-d, --envDirectories [environment_key] Environment variable that contains the directories, for example a package.json config var would be: npm_config_myVar | ||
-v, --verbose More verbose output | ||
@@ -21,0 +22,0 @@ -h, --help output usage information |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
24162
12
210
47