sudo-prompt/test-concurrent.js

30 lines
664 B
JavaScript
Raw Normal View History

var sudo = require('./');
var exec = require('child_process').exec;
function kill(end) {
2016-07-15 17:13:03 +02:00
if (process.platform === 'win32') return end();
exec('sudo -k', end);
}
kill(
function() {
var options = {
name: 'Sudo Prompt'
};
2016-07-15 17:13:03 +02:00
if (process.platform === 'win32') {
var sleep = 'timeout /t 10\r\necho world';
} else {
var sleep = 'sleep 10 && echo world';
}
sudo.exec(sleep, options,
function(error, stdout, stderr) {
console.log(error, stdout, stderr);
}
);
sudo.exec('echo hello', options,
function(error, stdout, stderr) {
console.log(error, stdout, stderr);
}
);
}
);