1/* eslint-disable node-core/require-common-first, node-core/required-modules */ 2'use strict'; 3 4const fs = require('fs'); 5const path = require('path'); 6 7function rimrafSync(pathname) { 8 fs.rmdirSync(pathname, { maxRetries: 3, recursive: true }); 9} 10 11const testRoot = process.env.NODE_TEST_DIR ? 12 fs.realpathSync(process.env.NODE_TEST_DIR) : path.resolve(__dirname, '..'); 13 14// Using a `.` prefixed name, which is the convention for "hidden" on POSIX, 15// gets tools to ignore it by default or by simple rules, especially eslint. 16const tmpdirName = '.tmp.' + (process.env.TEST_THREAD_ID || '0'); 17const tmpPath = path.join(testRoot, tmpdirName); 18 19function refresh() { 20 rimrafSync(this.path); 21 fs.mkdirSync(this.path); 22} 23 24module.exports = { 25 path: tmpPath, 26 refresh 27}; 28