Test options.env

This commit is contained in:
Joran Dirk Greef 2019-06-01 17:20:19 +02:00
parent dac09e3c7b
commit ab3a0bd981

15
test.js
View file

@ -20,16 +20,23 @@ function icns() {
kill( kill(
function() { function() {
var options = { var options = {
env: { 'SUDO_PROMPT_TEST_ENV': 'hello world' },
icns: icns(), icns: icns(),
name: 'Electron' name: 'Electron'
}; };
var command = 'echo hello';
if (process.platform === 'win32') { if (process.platform === 'win32') {
var expected = 'hello\r\n'; var command = 'echo %SUDO_PROMPT_TEST_ENV%';
var expected = 'hello world\r\n';
} else { } else {
var expected = 'hello\n'; var command = 'echo $SUDO_PROMPT_TEST_ENV';
var expected = 'hello world\n';
} }
console.log('sudo.exec(' + JSON.stringify(command) + ', ' + JSON.stringify(options) + ')'); console.log(
'sudo.exec(' +
JSON.stringify(command) + ', ' +
JSON.stringify(options) +
')'
);
sudo.exec(command, options, sudo.exec(command, options,
function(error, stdout, stderr) { function(error, stdout, stderr) {
console.log('error: ' + error); console.log('error: ' + error);