Comparing version 0.1.2 to 0.1.3
@@ -23,5 +23,6 @@ #!/usr/bin/env node | ||
// should we run the command on all the dependencies, too? | ||
const recursive = !!yargs_1.argv.recursive || !!yargs_1.argv.r; | ||
const fastExit = !!yargs_1.argv.fastExit; | ||
const collectLogs = !!yargs_1.argv.collectLogs; | ||
const recursive = yargs_1.argv.recursive || yargs_1.argv.r || false; | ||
const fastExit = yargs_1.argv.fastExit || false; | ||
const collectLogs = yargs_1.argv.collectLogs || false; | ||
const addPrefix = yargs_1.argv.prefix === undefined ? true : false; | ||
const cmd = yargs_1.argv._[0]; | ||
@@ -70,6 +71,5 @@ const pkgName = yargs_1.argv._[1]; | ||
runner = Promise.mapSeries(stages, stg => { | ||
console.log('----- RUNNING A STAGE -----'); | ||
console.log('Packages in stage:', stg.map(p => p.name).join(', ')); | ||
console.log(`-- Packages in stage: ${stg.map(p => p.name).join(', ')} --`); | ||
const cmds = stg.map(genCmd); | ||
return new parallelshell_1.RunAll(cmds, runMode, { fastExit, collectLogs }).finishedAll; | ||
return new parallelshell_1.RunAll(cmds, runMode, { fastExit, collectLogs, addPrefix }).finishedAll; | ||
}); | ||
@@ -79,4 +79,4 @@ } | ||
const cmds = sortedInstrs.map(genCmd); | ||
runner = new parallelshell_1.RunAll(cmds, 'parallel', { fastExit, collectLogs }).finishedAll; | ||
runner = new parallelshell_1.RunAll(cmds, 'parallel', { fastExit, collectLogs, addPrefix }).finishedAll; | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -16,2 +16,3 @@ /// <reference types="node" /> | ||
collectLogs?: boolean; | ||
addPrefix?: boolean; | ||
}; | ||
@@ -21,2 +22,3 @@ constructor(cmd: string, pkgName: string, opts?: { | ||
collectLogs?: boolean; | ||
addPrefix?: boolean; | ||
}); | ||
@@ -31,2 +33,3 @@ private _start(cmd); | ||
collectLogs: boolean; | ||
addPrefix: boolean; | ||
}; | ||
@@ -39,2 +42,3 @@ constructor(pkgCmds: { | ||
collectLogs: boolean; | ||
addPrefix: boolean; | ||
}); | ||
@@ -41,0 +45,0 @@ /** |
@@ -8,5 +8,11 @@ "use strict"; | ||
const child_process_1 = require("child_process"); | ||
var split = require('split'); | ||
let wait, verbose; | ||
wait = true; | ||
verbose = true; | ||
function prefixLine(pkgName, line, prefixLength = 15) { | ||
const pkgNameShort = pkgName.slice(0, prefixLength - 1); | ||
const spaces = ' '.repeat(Math.max(1, prefixLength - pkgName.length)); | ||
return `${pkgNameShort}${spaces} | ${line}`; | ||
} | ||
class CmdProcess { | ||
@@ -16,3 +22,2 @@ constructor(cmd, pkgName, opts = {}) { | ||
this.opts = opts; | ||
console.log('Executing cmd:', cmd); | ||
this._start(cmd); | ||
@@ -49,4 +54,4 @@ this.finished = new Promise((resolve, reject) => { | ||
} | ||
const stdErr = []; | ||
const stdOut = []; | ||
const stdOutBuffer = []; | ||
const stdErrBuffer = []; | ||
this.cmd = cmd; | ||
@@ -56,21 +61,28 @@ this.cp = child_process_1.spawn(sh, [shFlag, cmd], { | ||
env: process.env, | ||
stdio: this.opts.collectLogs ? ['pipe'] : ['pipe', process.stdout, process.stderr] | ||
stdio: ['pipe'] | ||
}); | ||
if (this.opts.collectLogs) { | ||
this.cp.stdout.on('data', chunk => { | ||
chunk instanceof Buffer ? stdOut.push(chunk.toString()) : stdOut.push(chunk); | ||
this.cp.stdout.pipe(split()).on('data', (line) => { | ||
stdOutBuffer.push(line); | ||
}); | ||
this.cp.stderr.on('data', chunk => { | ||
chunk instanceof Buffer ? stdErr.push(chunk.toString()) : stdErr.push(chunk); | ||
this.cp.stderr.pipe(split()).on('data', (line) => { | ||
stdErrBuffer.push(line); | ||
}); | ||
this.cp.on('close', () => { | ||
console.log(stdOut | ||
.join('') | ||
.trim() | ||
.split('\n') | ||
.map(l => `${this.pkgName} | ${l}`) | ||
console.log(stdOutBuffer | ||
.map(line => (this.opts.addPrefix ? prefixLine(this.pkgName, line) : line)) | ||
.join('\n')); | ||
console.error(stdErr.join('').trim()); | ||
console.error(stdErrBuffer | ||
.map(line => (this.opts.addPrefix ? prefixLine(this.pkgName, line) : line)) | ||
.join('\n')); | ||
}); | ||
} | ||
else { | ||
this.cp.stdout.pipe(split()).on('data', (line) => { | ||
console.log(this.opts.addPrefix ? prefixLine(this.pkgName, line) : line); | ||
}); | ||
this.cp.stderr.pipe(split()).on('data', (line) => { | ||
console.error(this.opts.addPrefix ? prefixLine(this.pkgName, line) : line); | ||
}); | ||
} | ||
} | ||
@@ -87,3 +99,4 @@ } | ||
rejectOnNonZeroExit: this.opts.fastExit, | ||
collectLogs: this.opts.collectLogs | ||
collectLogs: this.opts.collectLogs, | ||
addPrefix: this.opts.addPrefix | ||
}); | ||
@@ -99,3 +112,4 @@ child.cp.on('close', code => code > 0 && this.closeAll.bind(this)); | ||
rejectOnNonZeroExit: this.opts.fastExit, | ||
collectLogs: this.opts.collectLogs | ||
collectLogs: this.opts.collectLogs, | ||
addPrefix: this.opts.addPrefix | ||
}); | ||
@@ -102,0 +116,0 @@ child.cp.on('close', code => code > 0 && this.closeAll.bind(this)); |
{ | ||
"name": "wsrun", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": | ||
@@ -14,3 +14,9 @@ "executes commands on packages in parallel, but is aware of the dependencies between them", | ||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", | ||
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json"] | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js", | ||
"jsx", | ||
"json" | ||
] | ||
}, | ||
@@ -42,6 +48,8 @@ "bin": { | ||
"dependencies": { | ||
"@types/split": "^0.3.28", | ||
"bluebird": "^3.5.1", | ||
"glob": "^7.1.2", | ||
"lodash": "^4.17.4" | ||
"lodash": "^4.17.4", | ||
"split": "^1.0.1" | ||
} | ||
} |
@@ -19,4 +19,4 @@ # Workspace command runner | ||
--fast-exit if at least one command exits with code > 0, abort | ||
--collect-output (not impl) collect per-package stdout, print everything at the end, grouped | ||
--prefix-logs (not impl) prefix stdout lines with "package_name |" | ||
--collect-output collect per-package stdout, print everything at the end, grouped | ||
--no-prefix don't prefix output with "package_name |" | ||
--bin=yarn which program should we pass the cmd to | ||
@@ -23,0 +23,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
34159
518
1
5
+ Added@types/split@^0.3.28
+ Addedsplit@^1.0.1
+ Added@types/node@22.7.4(transitive)
+ Added@types/split@0.3.28(transitive)
+ Addedsplit@1.0.1(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedundici-types@6.19.8(transitive)