Socket
Socket
Sign inDemoInstall

wsrun

Package Overview
Dependencies
Maintainers
3
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wsrun - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

3

build/parallelshell.d.ts

@@ -11,3 +11,3 @@ /// <reference types="node" />

collectLogs?: boolean;
addPrefix?: boolean;
prefixer?: (pkg: string, line: string) => string;
doneCriteria?: string;

@@ -54,2 +54,3 @@ path?: string;

private throat;
prefixer: (pkg: string, line: string) => string;
constructor(pkgJsons: PkgJson[], opts: GraphOptions, pkgPaths: Dict<string>);

@@ -56,0 +57,0 @@ private closeAll;

@@ -8,8 +8,54 @@ "use strict";

const child_process_1 = require("child_process");
const split = require("split");
const originalSplit = require("split");
let mkThroat = require('throat')(Promise);
let passThrough = f => f();
function prefixLine(pkgName, line, prefixLength = 15) {
const pkgNameShort = pkgName.slice(0, prefixLength - 1);
const spaces = ' '.repeat(Math.max(1, prefixLength - pkgName.length));
let MaxPrefixLen = 15;
class NameShortener {
constructor(names, maxLen) {
this.prefixLen = 0;
this.freqMap = new Map();
this.shortNameMap = new Map();
this.prefixer = (pkg, line) => {
return prefixLine(this.fix(pkg), line, this.prefixLen);
};
let max = 0;
for (let pkg of names) {
for (let word of pkg.split(/[-/]/g)) {
let f = this.freqMap.get(word.toLowerCase()) || 0;
this.freqMap.set(word.toLowerCase(), f + 1);
}
max = Math.max(pkg.length, max);
}
this.prefixLen = Math.min(maxLen, max);
}
fix(pkgName) {
let sname = this.shortNameMap.get(pkgName);
if (!sname) {
sname = pkgName;
let mostFrequent = pkgName
.split(/[-/]/)
.map(word => ({ word, freq: this.freqMap.get(word.toLowerCase()) }))
.filter(w => w.freq && w.freq > 0 && w.word.length > 2)
.sort((w1, w2) => {
let f1f2 = (w2.freq || 0) - (w1.freq || 0);
if (f1f2 != 0)
return f1f2;
return w2.word.length - w1.word.length;
})
.map(w => w.word);
while (sname.length > this.prefixLen && mostFrequent.length > 1) {
let best = mostFrequent.shift();
if (!best)
break;
let takeOnly = Math.max(1, best.length - (sname.length - this.prefixLen) - 1);
sname = sname.replace(new RegExp(best + '[-/]', 'gi'), best.substr(0, takeOnly) + '..');
}
this.shortNameMap.set(pkgName, sname);
}
return sname || 'WTH';
}
}
function prefixLine(pkgName, line, prefixLength = MaxPrefixLen) {
const pkgNameShort = pkgName.slice(0, prefixLength);
const spaces = ' '.repeat(Math.max(0, prefixLength - pkgName.length));
return `${pkgNameShort}${spaces} | ${line}`;

@@ -25,2 +71,5 @@ }

}
const SPLIT_OPTIONS = { trailing: false };
const SPLIT_MAPPER = (x) => x;
const split = () => originalSplit(/\r?\n/, SPLIT_MAPPER, SPLIT_OPTIONS);
class CmdProcess {

@@ -66,3 +115,3 @@ constructor(cmd, pkgName, opts = {}) {

autoPrefix(line) {
return this.opts.addPrefix ? prefixLine(this.pkgName, line) : line;
return this.opts.prefixer ? this.opts.prefixer(this.pkgName, line) : line;
}

@@ -91,3 +140,5 @@ _start(cmd) {

env: Object.assign(process.env, { FORCE_COLOR: process.stdout.isTTY }),
stdio: this.opts.collectLogs || this.opts.addPrefix || this.opts.doneCriteria ? 'pipe' : 'inherit'
stdio: this.opts.collectLogs || this.opts.prefixer != null || this.opts.doneCriteria
? 'pipe'
: 'inherit'
});

@@ -130,2 +181,3 @@ if (this.cp.stdout)

this.throat = passThrough;
this.prefixer = new NameShortener(this.pkgJsons.map(p => p.name), MaxPrefixLen).prefixer;
this.closeAll = () => {

@@ -176,3 +228,3 @@ console.log('Stopping', this.children.length, 'active children');

collectLogs: this.opts.collectLogs,
addPrefix: this.opts.addPrefix,
prefixer: this.opts.addPrefix ? this.prefixer : undefined,
doneCriteria: this.opts.doneCriteria,

@@ -179,0 +231,0 @@ path: this.pkgPaths[pkg]

{
"name": "wsrun",
"version": "1.2.2",
"version": "1.2.3",
"description": "executes commands on packages in parallel, but is aware of the dependencies between them",

@@ -5,0 +5,0 @@ "main": "./build/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc