Replace the homegrown rimrafsync implementation in test/common with
a call to `fs.rmdirSync(path, { recursive: true })`.
Fixes: https://github.com/nodejs/node/issues/30620
Fixes: https://github.com/nodejs/node/issues/30844
PR-URL: https://github.com/nodejs/node/pull/30849
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
27 lines
768 B
JavaScript
27 lines
768 B
JavaScript
/* eslint-disable node-core/require-common-first, node-core/required-modules */
|
|
'use strict';
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
function rimrafSync(pathname) {
|
|
fs.rmdirSync(pathname, { maxRetries: 3, recursive: true });
|
|
}
|
|
|
|
const testRoot = process.env.NODE_TEST_DIR ?
|
|
fs.realpathSync(process.env.NODE_TEST_DIR) : path.resolve(__dirname, '..');
|
|
|
|
// Using a `.` prefixed name, which is the convention for "hidden" on POSIX,
|
|
// gets tools to ignore it by default or by simple rules, especially eslint.
|
|
const tmpdirName = '.tmp.' + (process.env.TEST_THREAD_ID || '0');
|
|
const tmpPath = path.join(testRoot, tmpdirName);
|
|
|
|
function refresh() {
|
|
rimrafSync(this.path);
|
|
fs.mkdirSync(this.path);
|
|
}
|
|
|
|
module.exports = {
|
|
path: tmpPath,
|
|
refresh
|
|
};
|