New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@travetto/exec

Package Overview
Dependencies
Maintainers
1
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@travetto/exec - npm Package Compare versions

Comparing version 0.0.23 to 0.0.24

test/docker-stdin.ts

2

package.json

@@ -17,3 +17,3 @@ {

},
"version": "0.0.23"
"version": "0.0.24"
}

@@ -7,5 +7,5 @@ import * as child_process from 'child_process';

import { CommonProcess, ChildOptions } from './types';
import { CommonProcess, ChildOptions, ExecutionResult } from './types';
import { spawn, WithOpts } from './util';
import { Shutdown, rimraf } from '@travetto/base';
import { Shutdown, rimraf, isPlainObject } from '@travetto/base';
import { CpuInfo } from 'os';

@@ -35,2 +35,4 @@

public evict: boolean = false;
public interactive: boolean = false;
public tty: boolean = false;

@@ -44,2 +46,4 @@ private env: { [key: string]: string } = {};

private deleteOnFinish = false;
constructor(private image: string, container?: string) {

@@ -54,2 +58,7 @@ this.container = container || `${process.env.DOCKER_NS || image}-${Date.now()}-${Math.random()}`.replace(/[^A-Z0-9a-z\-]/g, '');

setDeleteOnFinish(yes: boolean) {
this.deleteOnFinish = yes;
return this;
}
createTempVolume(volume: string) {

@@ -89,2 +98,12 @@ const p = fs.mkdtempSync(`/tmp/${this.image.replace(/[^A-Za-z0-9]/g, '_')}`);

setInteractive(on: boolean) {
this.interactive = on;
return this;
}
setTTY(on: boolean) {
this.tty = on;
return this;
}
async waitForPort(port: number, ms = 5000) {

@@ -117,7 +136,48 @@ const start = Date.now()

async run(...args: any[]) {
// Kill existing
await this.destroy();
await this.removeDanglingVolumes();
getFlags(extra?: string[]) {
const flags = [this.cmd, 'run', `--name=${this.container}`];
if (this.workingDir) {
flags.push('-w', this.workingDir);
}
if (this.deleteOnFinish) {
flags.push('--rm');
}
if (this.interactive) {
flags.push('-i');
}
if (this.tty) {
flags.push('-t');
}
for (const k of Object.keys(this.volumes)) {
flags.push('-v', `${k}:${this.volumes[k]}`)
}
for (const k of Object.keys(this.tempVolumes)) {
flags.push('-v', `${this.tempVolumes[k]}:${k}`);
}
for (const k of Object.keys(this.ports)) {
flags.push('-p', `${k}:${this.ports[k]}`);
}
for (const k of Object.keys(this.env)) {
flags.push('-e', `"${k}=${this.env[k]}"`);
}
if (extra) {
flags.push(...extra);
}
return flags;
}
run(first: string, ...args: any[]): Promise<ExecutionResult>
run(options: { args?: any[], flags?: string[] }): Promise<[CommonProcess, Promise<ExecutionResult>]>
async run(...args: any[]): Promise<ExecutionResult | [CommonProcess, Promise<ExecutionResult>]> {
const options = isPlainObject(args[0]) ? args[0] : {
args
};
if (!this.deleteOnFinish) {
// Kill existing
await this.destroy();
await this.removeDanglingVolumes();
}
// Make temp dirs

@@ -130,22 +190,10 @@ const mkdirAll = Object.keys(this.tempVolumes).map(x => mkdir(x).catch(e => { }));

try {
const finalArgs = [this.cmd, 'run', `--name=${this.container}`];
if (this.workingDir) {
finalArgs.push('-w', this.workingDir);
}
for (const k of Object.keys(this.volumes)) {
finalArgs.push('-v', `${k}:${this.volumes[k]}`)
}
for (const k of Object.keys(this.tempVolumes)) {
finalArgs.push('-v', `${this.tempVolumes[k]}:${k}`);
}
for (const k of Object.keys(this.ports)) {
finalArgs.push('-p', `${k}:${this.ports[k]}`);
}
for (const k of Object.keys(this.env)) {
finalArgs.push('-e', `"${k}=${this.env[k]}"`);
}
const flags = this.getFlags(options.flags);
console.debug('Running', [...finalArgs, this.image, ...args]);
console.debug('Running', [...flags, this.image, ...(options.args || [])]);
[this._proc, prom] = spawn([...finalArgs, this.image, ...args.map(z => `${z}`)].join(' '), { shell: false });
[this._proc, prom] = spawn([...flags, this.image, ...(options.args || []).map((z: any) => `${z}`)].join(' '), {
shell: false,
});
this._proc.unref();

@@ -159,3 +207,7 @@ } catch (e) {

return prom;
if (isPlainObject(args[0])) {
return [this._proc, prom];
} else {
return prom;
}
}

@@ -162,0 +214,0 @@

@@ -6,2 +6,3 @@ import * as child_process from 'child_process';

quiet?: boolean;
stdin?: string | Buffer | NodeJS.ReadableStream;
timeoutKill?: (proc: child_process.ChildProcess) => Promise<void>;

@@ -21,2 +22,5 @@ };

pid: number;
stdin: NodeJS.WritableStream;
stderr: NodeJS.ReadableStream;
stdout: NodeJS.ReadableStream;
send?(message: any, sendHandle?: any): void;

@@ -23,0 +27,0 @@ removeListener(name: string, f: Function): void;

@@ -5,3 +5,3 @@ #!/usr/bin/env node

.then(x =>
require(process.env.SRC || './docker.ts')
);
require(process.env.SRC || './docker-stdin.ts')
);
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