Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 26b92a1

Browse files
author
Alan Shaw
authored
fix: clean repo func on windows (#2243)
`rimraf.sync` does not retry when it encounters errors on windows. The async version retries a number of times before failing. See isaacs/rimraf#72 for context on why rimraf on windows might error. License: MIT Signed-off-by: Alan Shaw <[email protected]>
1 parent 04aa63c commit 26b92a1

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

test/http-api/routes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('HTTP API', () => {
5858
this.timeout(50 * 1000)
5959

6060
await http.api.stop()
61-
clean(repoTests)
61+
await clean(repoTests)
6262
})
6363

6464
describe('## http-api spec tests for custom config', () => {
@@ -81,7 +81,7 @@ describe('HTTP API', () => {
8181
this.timeout(50 * 1000)
8282

8383
await http.api.stop()
84-
clean(repoTests)
84+
await clean(repoTests)
8585
})
8686

8787
describe('## http-api spec tests for default config', () => {

test/utils/clean.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
'use strict'
22

33
const rimraf = require('rimraf')
4-
const fs = require('fs')
4+
const fs = require('fs').promises
5+
const { promisify } = require('util')
56

6-
module.exports = (dir) => {
7+
module.exports = async dir => {
78
try {
8-
fs.accessSync(dir)
9+
await fs.access(dir)
910
} catch (err) {
1011
// Does not exist so all good
1112
return
1213
}
1314

14-
rimraf.sync(dir)
15+
return promisify(rimraf)(dir)
1516
}

test/utils/create-repo-nodejs.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ function createTempRepo (repoPath) {
1616
series([
1717
// ignore err, might have been closed already
1818
(cb) => repo.close(() => cb()),
19-
(cb) => {
20-
clean(repoPath)
21-
cb()
22-
}
19+
(cb) => clean(repoPath).then(cb, cb)
2320
], done)
2421
}
2522

test/utils/on-and-off.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ function off (tests) {
3030
return thing.ipfs('init')
3131
})
3232

33-
after(function (done) {
33+
after(function () {
3434
this.timeout(20 * 1000)
35-
clean(repoPath)
36-
setImmediate(done)
35+
return clean(repoPath)
3736
})
3837

3938
tests(thing)

0 commit comments

Comments
 (0)