Remove dependency on locale language when detecting sudo error
This commit is contained in:
parent
210a928248
commit
d08ec680f3
1 changed files with 1 additions and 3 deletions
4
index.js
4
index.js
|
@ -17,7 +17,7 @@ function attempt(attempts, command, options, end) {
|
||||||
// display an error message and exit.
|
// display an error message and exit.
|
||||||
var childProcess = Node.child.exec('/usr/bin/sudo -n ' + command,
|
var childProcess = Node.child.exec('/usr/bin/sudo -n ' + command,
|
||||||
function(error, stdout, stderr) {
|
function(error, stdout, stderr) {
|
||||||
if (/sudo: a password is required/i.test(stderr)) {
|
if (/sudo: /i.test(stderr)) {
|
||||||
if (attempts > 0) return end(new Error('User did not grant permission.'));
|
if (attempts > 0) return end(new Error('User did not grant permission.'));
|
||||||
if (Node.process.platform === 'linux') {
|
if (Node.process.platform === 'linux') {
|
||||||
// Linux will probably use TTY tickets for sudo timestamps.
|
// Linux will probably use TTY tickets for sudo timestamps.
|
||||||
|
@ -32,8 +32,6 @@ function attempt(attempts, command, options, end) {
|
||||||
attempt(++attempts, command, options, end); // Cannot use ++ suffix here.
|
attempt(++attempts, command, options, end); // Cannot use ++ suffix here.
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else if (!error && /^sudo:/i.test(stderr)) {
|
|
||||||
end(new Error('Unexpected stderr from sudo command without corresponding error: ' + stderr));
|
|
||||||
} else {
|
} else {
|
||||||
end(error, stdout, stderr);
|
end(error, stdout, stderr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue