Comparing version 3.6.6 to 4.0.0
@@ -66,3 +66,3 @@ "use strict"; | ||
if (!this.opts.silent) | ||
console.error(this.autoPrefix(msg)); | ||
console.error(this.autoAugmentLine(msg)); | ||
if (this.opts.rejectOnNonZeroExit) | ||
@@ -87,2 +87,12 @@ return this._finished.reject(new Error(msg)); | ||
} | ||
autoPathRewrite(line) { | ||
return this.opts.pathRewriter | ||
? this.opts.pathRewriter(this.opts.path, this.pkgName, line) | ||
: line; | ||
} | ||
autoAugmentLine(line) { | ||
line = this.autoPathRewrite(line); | ||
line = this.autoPrefix(line); | ||
return line; | ||
} | ||
_start(cmd) { | ||
@@ -118,3 +128,3 @@ let sh; | ||
else | ||
console.log(this.autoPrefix(line)); | ||
console.log(this.autoAugmentLine(line)); | ||
if (this.doneCriteria && this.doneCriteria.test(line)) | ||
@@ -128,3 +138,3 @@ this._finished.resolve(); | ||
else | ||
console.error(this.autoPrefix(line)); | ||
console.error(this.autoAugmentLine(line)); | ||
if (this.doneCriteria && this.doneCriteria.test(line)) | ||
@@ -136,5 +146,5 @@ this._finished.resolve(); | ||
if (stdOutBuffer.length) | ||
console.log(stdOutBuffer.map(line => this.autoPrefix(line)).join('\n')); | ||
console.log(stdOutBuffer.map(line => this.autoAugmentLine(line)).join('\n')); | ||
if (stdErrBuffer.length) | ||
console.error(stdErrBuffer.map(line => this.autoPrefix(line)).join('\n')); | ||
console.error(stdErrBuffer.map(line => this.autoAugmentLine(line)).join('\n')); | ||
}); | ||
@@ -141,0 +151,0 @@ } |
@@ -5,3 +5,3 @@ "use strict"; | ||
function fixPaths(workspacePath, packagePath, logLine) { | ||
return logLine.replace(/([\u001b][^m]*m|[^/_@0-9a-zA-Z])(([-_0-9a-zA-Z.]([^\s/'"*]*[/]){1,})([^/'"*]+)\.[0-9a-zA-Z]{1,6})/, (_m, before, file) => { | ||
return logLine.replace(/([\u001b][^m]*m|[^/_@0-9a-zA-Z])(([-_0-9a-zA-Z.]([^\s/'"*:]*[/]){1,})([^/'"*]+)\.[0-9a-zA-Z]{1,6})/, (_m, before, file) => { | ||
return before + path.relative(workspacePath, path.resolve(packagePath, file)); | ||
@@ -8,0 +8,0 @@ }); |
@@ -36,3 +36,7 @@ "use strict"; | ||
}); | ||
it('doesnt rewrite URLs', () => { | ||
let res = fix_paths_1.fixPaths('/a/b/c', '/a/b/c/packages/p', 'Testing http://src/test.ts'); | ||
expect(res).toEqual('Testing http://src/test.ts'); | ||
}); | ||
}); | ||
//# sourceMappingURL=fix-paths.spec.js.map |
@@ -1,3 +0,5 @@ | ||
#!/usr/bin/env node | ||
"use strict"; | ||
/** | ||
* Tool for running command in yarn workspaces. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -11,2 +13,3 @@ const fs = require("fs"); | ||
let yargsParser = yargs | ||
.env('WSRUN') | ||
.wrap(yargs.terminalWidth() - 1) | ||
@@ -59,2 +62,3 @@ .updateStrings({ | ||
'no-prefix', | ||
'no-path-rewrite', | ||
'bin', | ||
@@ -88,2 +92,6 @@ 'done-criteria', | ||
}, | ||
'rewrite-paths': { | ||
boolean: true, | ||
describe: 'Rewrite relative paths in the standard output, by prepending the <root_folder>/<package_name>.' | ||
}, | ||
bin: { | ||
@@ -141,2 +149,4 @@ default: 'yarn', | ||
const addPrefix = argv.prefix === undefined ? true : false; | ||
console.log(argv); | ||
const rewritePaths = Boolean(argv.rewritePaths); | ||
const doneCriteria = argv.doneCriteria; | ||
@@ -155,3 +165,10 @@ const exclude = (argv.exclude && (Array.isArray(argv.exclude) ? argv.exclude : [argv.exclude])) || []; | ||
const workspaceGlobs = packageJsonWorkspacesNohoistFormat || packageJsonWorkspaces || ['packages/*']; | ||
const pkgs = workspace_1.listPkgs('./', workspaceGlobs); | ||
let pkgs; | ||
try { | ||
pkgs = workspace_1.listPkgs('./', workspaceGlobs); | ||
} | ||
catch (err) { | ||
console.error(chalk_1.default.red(`\nERROR: ${err.message}`)); | ||
process.exit(1); | ||
} | ||
const pkgPaths = _.mapValues(_.keyBy(pkgs, p => p.json.name), v => v.path); | ||
@@ -164,2 +181,3 @@ const pkgJsons = _.map(pkgs, pkg => pkg.json); | ||
addPrefix, | ||
rewritePaths, | ||
mode: mode, | ||
@@ -166,0 +184,0 @@ recursive, |
@@ -39,2 +39,3 @@ "use strict"; | ||
this.prefixer = new Prefixer(this.opts.workspacePath).prefixer; | ||
this.pathRewriter = fix_paths_1.fixPaths; | ||
this.closeAll = () => { | ||
@@ -150,2 +151,3 @@ console.log('Stopping', this.children.length, 'active children'); | ||
prefixer: this.opts.addPrefix ? this.prefixer : undefined, | ||
pathRewriter: this.opts.rewritePaths ? this.pathRewriter : undefined, | ||
doneCriteria: this.opts.doneCriteria, | ||
@@ -152,0 +154,0 @@ path: this.pkgPaths[pkg] |
@@ -27,2 +27,4 @@ "use strict"; | ||
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8')); | ||
if (!pkgJson.name) | ||
throw new Error(`Package in directory ${f} has no name in package.json`); | ||
packages[pkgJson.name] = { | ||
@@ -29,0 +31,0 @@ path: path.join(wsRoot, f), |
{ | ||
"name": "wsrun", | ||
"version": "3.6.6", | ||
"version": "4.0.0", | ||
"description": "executes commands on packages in parallel, but is aware of the dependencies between them", | ||
@@ -11,12 +11,3 @@ "main": "./build/index.js", | ||
"verbose": false, | ||
"transform": { | ||
"^.+\\.tsx?$": "ts-jest" | ||
}, | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js", | ||
"jsx", | ||
"json" | ||
], | ||
"preset": "ts-jest", | ||
"testPathIgnorePatterns": [ | ||
@@ -37,3 +28,3 @@ "<rootDir>/tmp", | ||
"bin": { | ||
"wsrun": "./build/index.js" | ||
"wsrun": "./bin/wsrun.js" | ||
}, | ||
@@ -66,3 +57,3 @@ "files": [ | ||
"watch": "tsc -w", | ||
"test": "jest", | ||
"test": "yarn build && jest", | ||
"test:watch": "jest --watch", | ||
@@ -69,0 +60,0 @@ "dev": "run-p test:watch watch", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
4
1
61198
19
697
1