@travetto/exec
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -29,4 +29,4 @@ { | ||
}, | ||
"version": "0.3.3", | ||
"gitHead": "c434a1f7931733b1c15983e6fa1dcea773f6af94" | ||
"version": "0.3.4", | ||
"gitHead": "8800de1d0a004ae78fd22a7c79202fa88b633e43" | ||
} |
@@ -7,3 +7,3 @@ import * as child_process from 'child_process'; | ||
import { Shutdown, FsUtil } from '@travetto/base'; | ||
import { Shutdown, ScanFs, ScanEntry } from '@travetto/base'; | ||
@@ -15,2 +15,3 @@ import { CommonProcess, ExecutionResult } from './types'; | ||
const mkdir = util.promisify(fs.mkdir); | ||
const unlinkFile = util.promisify(fs.unlink); | ||
@@ -262,2 +263,16 @@ function exec(command: string, opts?: WithOpts<child_process.SpawnOptions>) { | ||
async rimraf(pth: string) { | ||
const files = await ScanFs.scanDir({}, pth); | ||
for (const filter of [ | ||
ScanFs.isNotDir, | ||
(x: ScanEntry) => x.stats.isDirectory() | ||
]) { | ||
await Promise.all(files | ||
.filter(filter) | ||
.map(x => unlinkFile(x.file) | ||
.catch(e => { console.error(`Unable to delete ${e.file}`); })) | ||
); | ||
} | ||
} | ||
forceDestroy() { | ||
@@ -274,3 +289,3 @@ try { | ||
const temps = Object.keys(this.tempVolumes).map(x => FsUtil.rimraf(x).catch((e: any) => { })); | ||
const temps = Object.keys(this.tempVolumes).map(x => this.rimraf(x).catch((e: any) => { })); | ||
Promise.all(temps); | ||
@@ -297,3 +312,3 @@ | ||
console.debug('Cleaning', this.image, this.container); | ||
const temps = Object.keys(this.tempVolumes).map(x => FsUtil.rimraf(x).catch((e: any) => { })); | ||
const temps = Object.keys(this.tempVolumes).map(x => this.rimraf(x).catch((e: any) => { })); | ||
await Promise.all(temps); | ||
@@ -300,0 +315,0 @@ } |
30860
817