From 9f808ffce1a3b0520fda597f0150e108479bb064 Mon Sep 17 00:00:00 2001 From: BenceSzalai Date: Mon, 15 Sep 2025 02:36:17 +0200 Subject: [PATCH] feat: add support for running remote in path with spaces, single- and double-quotes --- core/command/remote.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/core/command/remote.js b/core/command/remote.js index b2d9f76bc..003a9552d 100644 --- a/core/command/remote.js +++ b/core/command/remote.js @@ -4,6 +4,20 @@ const { exec } = require('child_process'); const getRemotePort = require('../util/getRemotePort'); const ssws = require.resolve('super-simple-web-server'); +function wrapPath(pathStr) { + if (!pathStr.includes('"')) { + return `"${pathStr}"`; + } + + // No windows below this point, since double-quotes are not allowed in paths. + + if (!pathStr.includes("'")) { + return `'${pathStr}'`; + } + + return `"${pathStr.replace(/"/g, '\\"')}"`; +} + module.exports = { execute: function (config) { const MIDDLEWARE_PATH = path.resolve(config.backstop, 'remote'); @@ -11,7 +25,7 @@ module.exports = { return new Promise(function (resolve, reject) { const port = getRemotePort(); - const commandStr = `node ${ssws} ${projectPath} ${MIDDLEWARE_PATH} --config=${config.backstopConfigFileName}`; + const commandStr = `node ${wrapPath(ssws)} ${wrapPath(projectPath)} ${wrapPath(MIDDLEWARE_PATH)} --config=${wrapPath(config.backstopConfigFileName)}`; const env = { SSWS_HTTP_PORT: port }; logger.log(`Starting remote with: ${commandStr} with env ${JSON.stringify(env)}`);