We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 83ff7be commit de77371Copy full SHA for de77371
1 file changed
test/common/tmpdir.js
@@ -5,17 +5,28 @@ const fs = require('fs');
5
const path = require('path');
6
const { pathToFileURL } = require('url');
7
const { isMainThread } = require('worker_threads');
8
+const isUnixLike = process.platform !== 'win32';
9
+let escapePOSIXShell;
10
11
function rmSync(pathname, useSpawn) {
12
if (useSpawn) {
- const escapedPath = pathname.replaceAll('\\', '\\\\');
- spawnSync(
13
- process.execPath,
14
- [
15
- '-e',
16
- `require("fs").rmSync("${escapedPath}", { maxRetries: 3, recursive: true, force: true });`,
17
- ],
18
- );
+ if (isUnixLike) {
+ escapePOSIXShell ??= require('./index.js').escapePOSIXShell;
+ for (let i = 0; i < 3; i++) {
+ const { status } = spawnSync(...escapePOSIXShell`rm -rf "${pathname}"`);
+ if (status === 0) {
+ break;
19
+ }
20
21
+ } else {
22
+ spawnSync(
23
+ process.execPath,
24
+ [
25
+ '-e',
26
+ `fs.rmSync(${JSON.stringify(pathname)}, { maxRetries: 3, recursive: true, force: true });`,
27
+ ],
28
+ );
29
30
} else {
31
fs.rmSync(pathname, { maxRetries: 3, recursive: true, force: true });
32
}
0 commit comments