Skip to content

Commit 2e35205

Browse files
committed
fix: Cleanup fail after build
Probably it is a fix Closes #724
1 parent 87616c0 commit 2e35205

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/util/tmp.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,23 @@ export class TmpDir {
5050
}
5151

5252
return this.tempDirectoryPromise
53-
.then(it => path.join(it, `temp-${(this.tmpFileCounter++).toString(16)}${suffix.startsWith(".") ? suffix : `-${suffix}`}`))
53+
.then(it => path.join(it, `t-${process.pid.toString(16)}-${(this.tmpFileCounter++).toString(16)}${suffix.startsWith(".") ? suffix : `-${suffix}`}`))
5454
}
5555

5656
cleanup(): Promise<any> {
57-
if (this.dir == null) {
57+
const dir = this.dir
58+
if (dir == null) {
5859
return BluebirdPromise.resolve()
5960
}
6061

61-
return remove(this.dir)
62-
.then(() => {
63-
this.dir = null
64-
})
62+
this.dir = null
63+
return remove(dir)
6564
.catch(e => {
66-
if (e.code !== "EPERM") {
67-
warn(`Cannot delete temporary dir "${this.dir}": ${(e.stack || e).toString()}`)
65+
if (e.code === "EPERM") {
66+
this.dir = dir
67+
}
68+
else {
69+
warn(`Cannot delete temporary dir "${dir}": ${(e.stack || e).toString()}`)
6870
}
6971
})
7072
}

0 commit comments

Comments
 (0)