Skip to content

Commit 697aa38

Browse files
committed
test(util): esnexted test-dir
1 parent 2288929 commit 697aa38

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

Diff for: test/util/test-dir.js

+13-17
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
11
'use strict'
22

3-
var mkdirp = require('mkdirp')
4-
var path = require('path')
5-
var rimraf = require('rimraf')
6-
var tap = require('tap')
3+
const mkdirp = require('mkdirp')
4+
const path = require('path')
5+
const rimraf = require('rimraf')
6+
const tap = require('tap')
77

8-
var cacheDir = path.resolve(__dirname, '../cache')
8+
const cacheDir = path.resolve(__dirname, '../cache')
99

1010
module.exports = testDir
1111
function testDir (filename) {
12-
var base = path.basename(filename, '.js')
13-
var dir = path.join(cacheDir, base)
14-
tap.beforeEach(function (cb) {
15-
reset(dir, function (err) {
12+
const base = path.basename(filename, '.js')
13+
const dir = path.join(cacheDir, base)
14+
tap.beforeEach(cb => {
15+
reset(dir, err => {
1616
if (err) { throw err }
1717
cb()
1818
})
1919
})
2020
if (!process.env.KEEPCACHE) {
21-
tap.tearDown(function () {
21+
tap.tearDown(() => {
2222
process.chdir(__dirname)
23-
try {
24-
rimraf.sync(dir)
25-
} catch (e) {
26-
if (process.platform !== 'win32') {
27-
throw e
28-
}
29-
}
23+
// This is ok cause this is the last
24+
// thing to run in the process
25+
rimraf(dir, () => {})
3026
})
3127
}
3228
return dir

0 commit comments

Comments
 (0)