@travetto/exec
Advanced tools
Comparing version 0.7.3 to 1.0.0-beta.1
@@ -11,3 +11,3 @@ { | ||
"dependencies": { | ||
"@travetto/base": "^0.7.3" | ||
"@travetto/base": "^1.0.0-beta.1" | ||
}, | ||
@@ -33,4 +33,4 @@ "homepage": "https://travetto.io", | ||
}, | ||
"version": "0.7.3", | ||
"gitHead": "3c47f7e9a053d761152c9f9c72653d041577b0c3" | ||
"version": "1.0.0-beta.1", | ||
"gitHead": "81e362a7d911693c635d2c077f3a03229c74d331" | ||
} |
@@ -19,3 +19,3 @@ import * as fs from 'fs'; | ||
private dockerCmd: string = 'docker'; | ||
private execState: ExecutionState; | ||
private pendingExecutions = new Set<ExecutionState>(); | ||
@@ -46,3 +46,3 @@ private container: string; | ||
this.evict = true; | ||
delete this.execState; | ||
this.pendingExecutions.clear(); | ||
} | ||
@@ -60,3 +60,4 @@ throw e; | ||
get id() { | ||
return this.execState && !this.execState.process.killed ? this.execState.process.pid : -1; | ||
const first = this.pendingExecutions.size > 0 ? this.pendingExecutions.values().next().value : undefined; | ||
return first && !first.process.killed ? first.process.pid : -1; | ||
} | ||
@@ -195,4 +196,6 @@ | ||
let prom = toStop; | ||
if (this.execState) { | ||
prom = Promise.all([toStop, this.execState.result]).then(x => x[0]); | ||
if (this.pendingExecutions) { | ||
const pendingResults = [...this.pendingExecutions.values()].map(e => e.result); | ||
this.pendingExecutions.clear(); | ||
prom = Promise.all([toStop, ...pendingResults]).then(([first]) => first); | ||
} | ||
@@ -204,5 +207,8 @@ return prom; | ||
const flags = this.getRuntimeFlags(extraFlags); | ||
this.execState = this.runCmd('exec', ...flags, this.container, ...(args || [])); | ||
this.execState.result = this.execState.result.finally(() => delete this.execState); | ||
return this.execState; | ||
const execState = this.runCmd('exec', ...flags, this.container, ...(args || [])); | ||
this.pendingExecutions.add(execState); | ||
execState.result = execState.result.finally(() => this.pendingExecutions.delete(execState)); | ||
return execState; | ||
} | ||
@@ -220,6 +226,9 @@ | ||
const state = this.runCmd('run', `--name=${this.container}`, ...this.getFlags(flags), this.image, ...(args || [])); | ||
this.execState = this.watchForEviction(state); | ||
this.execState.process.unref(); | ||
return this.execState.result; | ||
const execState = this.runCmd('run', `--name=${this.container}`, ...this.getFlags(flags), this.image, ...(args || [])); | ||
this.pendingExecutions.add(execState); | ||
this.watchForEviction(execState); | ||
execState.process.unref(); | ||
return execState.result.finally(() => this.pendingExecutions.delete(execState)); | ||
} | ||
@@ -245,6 +254,6 @@ | ||
if (this.execState) { | ||
const state = this.execState; | ||
delete this.execState; | ||
await state.result; | ||
if (this.pendingExecutions.size) { | ||
const results = [...this.pendingExecutions.values()].map(x => x.result); | ||
this.pendingExecutions.clear(); | ||
await Promise.all(results); | ||
} | ||
@@ -251,0 +260,0 @@ |
@@ -16,3 +16,3 @@ import * as child_process from 'child_process'; | ||
let done = false; | ||
const finish = async function (result: ExecutionResult) { | ||
const finish = function (result: ExecutionResult) { | ||
if (done) { | ||
@@ -19,0 +19,0 @@ return; |
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
22328
483
+ Added@travetto/base@1.1.1(transitive)
+ Added@travetto/boot@1.1.2(transitive)
+ Added@types/node@12.20.55(transitive)
+ Added@types/source-map-support@0.5.10(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsource-map-support@0.5.21(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addedtypescript@4.9.5(transitive)
- Removed@travetto/base@0.7.3(transitive)
- Removed@travetto/boot@0.7.2(transitive)
- Removed@types/node@11.15.54(transitive)
- Removedtslib@1.14.1(transitive)
- Removedtypescript@3.9.10(transitive)
Updated@travetto/base@^1.0.0-beta.1