MCPcopy Index your code
hub / github.com/nodejs/node / rmSync

Function rmSync

test/common/tmpdir.js:11–33  ·  view source on GitHub ↗
(pathname, useSpawn)

Source from the content-addressed store, hash-verified

9let escapePOSIXShell;
10
11function rmSync(pathname, useSpawn) {
12 if (useSpawn) {
13 if (isUnixLike) {
14 escapePOSIXShell ??= require('./index.js').escapePOSIXShell;
15 for (let i = 0; i < 3; i++) {
16 const { status } = spawnSync(...escapePOSIXShell`rm -rf "${pathname}"`);
17 if (status === 0) {
18 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 }
33}
34
35const testRoot = process.env.NODE_TEST_DIR ?
36 fs.realpathSync(process.env.NODE_TEST_DIR) : path.resolve(__dirname, '..');

Callers 5

refreshFunction · 0.70
onexitFunction · 0.70
test.jsFile · 0.50
test-fs-glob.mjsFile · 0.50

Calls 4

escapePOSIXShellFunction · 0.85
rmSyncMethod · 0.80
requireFunction · 0.50
spawnSyncFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…