Polish macOS and Windows methods

This commit is contained in:
Joran Dirk Greef 2019-06-03 16:27:15 +02:00
parent 7e2db9e19e
commit 711dea9623

View file

@ -303,15 +303,14 @@ function MacCommand(instance, end) {
'sudo-prompt-command' 'sudo-prompt-command'
); );
var script = []; var script = [];
// Preserve current working directory. // Preserve current working directory:
// We do this for commands that rely on relative paths. // We do this for commands that rely on relative paths.
// This runs in a subshell and will not change the cwd of sudo-prompt-script. // This runs in a subshell and will not change the cwd of sudo-prompt-script.
var cwd = Node.process.cwd(); script.push('cd "' + EscapeDoubleQuotes(Node.process.cwd()) + '"');
script.push('cd "' + EscapeDoubleQuotes(cwd) + '"');
// Export environment variables: // Export environment variables:
for (var key in instance.options.env) { for (var key in instance.options.env) {
var value = EscapeDoubleQuotes(instance.options.env[key]); var value = instance.options.env[key];
script.push('export ' + key + '="' + value + '"'); script.push('export ' + key + '="' + EscapeDoubleQuotes(value) + '"');
} }
script.push(instance.command); script.push(instance.command);
script = script.join('\n'); script = script.join('\n');
@ -623,8 +622,8 @@ function WindowsWriteCommandScript(instance, end) {
// part of the environment variable value." // part of the environment variable value."
// In other words, Windows assigns everything that follows the equals sign // In other words, Windows assigns everything that follows the equals sign
// to the value of the variable, whereas Unix systems ignore double quotes. // to the value of the variable, whereas Unix systems ignore double quotes.
var value = instance.options.env[key].replace(/([<>\\|&^])/g, '^$1'); var value = instance.options.env[key];
script.push('set ' + key + '=' + value); script.push('set ' + key + '=' + value.replace(/([<>\\|&^])/g, '^$1'));
} }
script.push(instance.command); script.push(instance.command);
script = script.join('\r\n'); script = script.join('\r\n');