Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
| 1 |
'use strict' |
| 2 |
|
| 3 |
const path = require('path') |
| 4 |
const fs = require('fs') |
| 5 |
const makeDir = require('make-dir') |
| 6 |
const _rimraf = require('rimraf') |
| 7 |
const { promisify } = require('util') |
| 8 |
|
| 9 |
const rimraf = promisify(_rimraf) |
| 10 |
const mkdtemp = promisify(fs.mkdtemp) |
| 11 |
|
| 12 |
function tempDirSetup (t, testFile) { |
| 13 |
const { dir, name } = path.parse(testFile) |
| 14 |
const tempDirBase = path.resolve(dir, 'temp-dir-' + name) |
| 15 |
|
| 16 |
makeDir.sync(tempDirBase) |
| 17 |
|
| 18 |
// Do not use arrow function for beforeEach |
| 19 |
// or afterEach, they need this from tap. |
| 20 |
t.beforeEach(async function () { |
| 21 |
this.tempDir = await mkdtemp(tempDirBase + '/') |
| 22 |
}) |
| 23 |
|
| 24 |
t.afterEach(function () { |
| 25 |
return rimraf(this.tempDir) |
| 26 |
}) |
| 27 |
|
| 28 |
t.tearDown(() => rimraf(tempDirBase)) |
| 29 |
} |
| 30 |
|
| 31 |
module.exports = tempDirSetup |