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

fix: clean repo func on windows #2243

Merged
merged 1 commit into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/http-api/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('HTTP API', () => {
this.timeout(50 * 1000)

await http.api.stop()
clean(repoTests)
await clean(repoTests)
})

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

await http.api.stop()
clean(repoTests)
await clean(repoTests)
})

describe('## http-api spec tests for default config', () => {
Expand Down
9 changes: 5 additions & 4 deletions test/utils/clean.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
'use strict'

const rimraf = require('rimraf')
const fs = require('fs')
const fs = require('fs').promises
const { promisify } = require('util')

module.exports = (dir) => {
module.exports = async dir => {
try {
fs.accessSync(dir)
await fs.access(dir)
} catch (err) {
// Does not exist so all good
return
}

rimraf.sync(dir)
return promisify(rimraf)(dir)
}
5 changes: 1 addition & 4 deletions test/utils/create-repo-nodejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ function createTempRepo (repoPath) {
series([
// ignore err, might have been closed already
(cb) => repo.close(() => cb()),
(cb) => {
clean(repoPath)
cb()
}
(cb) => clean(repoPath).then(cb, cb)
], done)
}

Expand Down
5 changes: 2 additions & 3 deletions test/utils/on-and-off.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ function off (tests) {
return thing.ipfs('init')
})

after(function (done) {
after(function () {
this.timeout(20 * 1000)
clean(repoPath)
setImmediate(done)
return clean(repoPath)
})

tests(thing)
Expand Down