Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion core/command/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,28 @@ 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');
const projectPath = path.resolve(config.projectPath);

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)}`);
Expand Down