ultra-runner
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -5,2 +5,14 @@ # Changelog | ||
## [3.2.0](https://github.com/folke/ultra-runner/compare/v3.1.0...v3.2.0) (2020-03-28) | ||
### Features | ||
* ✨ add all vscode node procs under one combined vscode root ([b1e499b](https://github.com/folke/ultra-runner/commit/b1e499b35d3b1ef7d3c5d8608b5b7d5aa7fbd989)) | ||
### Other | ||
* **deps:** update dependency @types/node to v13.9.5 ([#51](https://github.com/folke/ultra-runner/issues/51)) ([379caa0](https://github.com/folke/ultra-runner/commit/379caa0b42aec800130057633482d125dc91c471)) | ||
## [3.1.0](https://github.com/folke/ultra-runner/compare/v3.0.1...v3.1.0) (2020-03-27) | ||
@@ -7,0 +19,0 @@ |
@@ -15,2 +15,3 @@ "use strict"; | ||
function parseCommand(proc) { | ||
var _a; | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
@@ -20,22 +21,27 @@ if (!proc.cmd) | ||
const ret = Object.assign(Object.assign({}, proc), { argv: shellwords_ts_1.split(proc.cmd).map((ss) => path_1.normalize(ss)), children: [] }); | ||
// shift node binary | ||
ret.argv.shift(); | ||
if (!ret.argv.length) | ||
ret.argv[0] = proc.cmd || proc.name; | ||
// shift all node options | ||
while (ret.argv.length && ret.argv[0].startsWith("-")) | ||
if ((_a = proc.cmd) === null || _a === void 0 ? void 0 : _a.includes("Visual Studio Code")) { | ||
ret.argv = ["vscode"]; | ||
} | ||
else { | ||
// shift node binary | ||
ret.argv.shift(); | ||
if (!ret.argv.length) | ||
ret.argv[0] = proc.cmd || proc.name; | ||
// Compact node_modules scripts | ||
ret.argv[0] = ret.argv[0].replace(/^.*node_modules\/.*\/([^/]+?)(\.[tj]s)?$/u, (_str, bin) => bin); | ||
// Compact all node_modules stuff | ||
ret.argv = ret.argv.map((arg) => arg.replace(/.*node_modules\//u, "")); | ||
// Replace common binaries | ||
const knownBins = ["npx", "npm"]; | ||
knownBins.forEach((r) => { | ||
if (new RegExp(`/${r}(.[tj]s)?$`, "u").test(ret.argv[0])) | ||
ret.argv[0] = r; | ||
}); | ||
ret.argv[0] = ret.argv[0].replace(/^\.bin\//u, ""); | ||
if (!ret.argv.length) | ||
ret.argv[0] = proc.cmd || proc.name; | ||
// shift all node options | ||
while (ret.argv.length && ret.argv[0].startsWith("-")) | ||
ret.argv.shift(); | ||
if (!ret.argv.length) | ||
ret.argv[0] = proc.cmd || proc.name; | ||
// Compact node_modules scripts | ||
ret.argv[0] = ret.argv[0].replace(/^.*node_modules\/.*\/([^/]+?)(\.[tj]s)?$/u, (_str, bin) => bin); | ||
// Compact all node_modules stuff | ||
ret.argv = ret.argv.map((arg) => arg.replace(/.*node_modules\//u, "")); | ||
// Replace common binaries | ||
const knownBins = ["npx", "npm"]; | ||
knownBins.forEach((r) => { | ||
if (new RegExp(`/${r}(.[tj]s)?$`, "u").test(ret.argv[0])) | ||
ret.argv[0] = r; | ||
}); | ||
ret.argv[0] = ret.argv[0].replace(/^\.bin\//u, ""); | ||
} | ||
ret.cwd = yield pidCwd(proc.pid); | ||
@@ -63,3 +69,7 @@ if (ret.cwd) { | ||
}) | ||
.filter((proc) => /node(\.exe)?/iu.test(path_1.basename(proc.name))); | ||
.filter((proc) => { | ||
var _a; | ||
return ((_a = proc.cmd) === null || _a === void 0 ? void 0 : _a.includes("Visual Studio Code")) || | ||
/node(\.exe)?/iu.test(path_1.basename(proc.name)); | ||
}); | ||
return yield Promise.all(procs.map((proc) => parseCommand(proc))); | ||
@@ -74,3 +84,28 @@ }); | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const procs = yield getProcessList(); | ||
let procs = yield getProcessList(); | ||
const vscode = { | ||
pid: -1, | ||
name: "vscode", | ||
ppid: 0, | ||
argv: ["vscode"], | ||
children: [], | ||
cpu: 0, | ||
memory: 0, | ||
}; | ||
procs | ||
.filter((proc) => proc.argv[0] == "vscode") | ||
.forEach((proc) => { | ||
vscode.pid = proc.pid; | ||
vscode.cpu = (vscode.cpu || 0) + (proc.cpu || 0); | ||
vscode.memory = (vscode.memory || 0) + (proc.memory || 0); | ||
}); | ||
vscode.cpu = Math.round((vscode.cpu || 0) * 10) / 10; | ||
vscode.memory = Math.round((vscode.memory || 0) * 10) / 10; | ||
const vscodePids = new Set(procs.filter((proc) => proc.argv[0] == "vscode").map((proc) => proc.pid)); | ||
procs.forEach((proc) => { | ||
if (vscodePids.has(proc.ppid)) | ||
proc.ppid = vscode.pid; | ||
}); | ||
procs = procs.filter((proc) => proc.argv[0] != "vscode"); | ||
procs.push(vscode); | ||
const pids = new Map(procs.map((proc) => [proc.pid, proc])); | ||
@@ -125,3 +160,3 @@ const children = new Set(); | ||
return [ | ||
`${chalk_1.default.magenta(proc.pid)}`, | ||
proc.pid === -1 ? "" : `${chalk_1.default.magenta(proc.pid)}`, | ||
proc.cpu === undefined | ||
@@ -128,0 +163,0 @@ ? "" |
{ | ||
"name": "ultra-runner", | ||
"description": "Smart and beautiful script runner that hijacks any `npm run`, `yarn` and `npx` calls for ultra fast execution", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"main": "lib/index.js", | ||
@@ -82,3 +82,3 @@ "repository": "http://github.com/folke/ultra-runner", | ||
"@types/json5": "0.0.30", | ||
"@types/node": "13.9.4", | ||
"@types/node": "13.9.5", | ||
"@types/prettier": "1.19.1", | ||
@@ -85,0 +85,0 @@ "@types/rimraf": "3.0.0", |
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
208973
2184