Skip to content

Commit

Permalink
test: launch rmdir with spawnSync
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Trott committed Jun 19, 2019
1 parent 82fe33f commit 2edb604
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/common/tmpdir.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable node-core/require-common-first, node-core/required-modules */
'use strict';

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

0 comments on commit 2edb604

Please sign in to comment.