Skip to content

Commit 2edb604

Browse files
committed
test: launch rmdir with spawnSync
In the `common/tmpdir` module used for testing, `rmdir` on Windows executes via `execSync()` which will fail if there is a space (or perhaps other special characters?) in `pathname`. Use `spawnSync()` instead so that args can be put into an array and escaping handled automatically.
1 parent 82fe33f commit 2edb604

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/common/tmpdir.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable node-core/require-common-first, node-core/required-modules */
22
'use strict';
33

4-
const { execSync } = require('child_process');
4+
const { spawnSync } = require('child_process');
55
const fs = require('fs');
66
const path = require('path');
77
const { debuglog } = require('util');
@@ -28,7 +28,7 @@ function rimrafSync(pathname, { spawn = true } = {}) {
2828
if (spawn && process.platform === 'win32' && st.isDirectory()) {
2929
try {
3030
// Try `rmdir` first.
31-
execSync(`rmdir /q /s ${pathname}`, { timout: 1000 });
31+
spawnSync('rmdir', ['/q', '/s', pathname], { timout: 1000 });
3232
} catch (e) {
3333
// Attempt failed. Log and carry on.
3434
debug(e);

0 commit comments

Comments
 (0)