Skip to content
This repository has been archived by the owner on Sep 23, 2021. It is now read-only.

Commit

Permalink
Fix Windows to return PERMISSION_DENIED Error even when Windows' error
Browse files Browse the repository at this point in the history
messages are internationalized.

Fixes: #96
  • Loading branch information
jorangreef committed Jun 1, 2019
1 parent dc0c5f5 commit 8d02007
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,15 +445,13 @@ function WindowsElevate(instance, end) {
command = command.join(' ');
var child = Node.child.exec(command,
function(error, stdout, stderr) {
if (error) {
if (/canceled by the user/i.test(error)) {
end(PERMISSION_DENIED);
} else {
end(error);
}
} else {
end();
}
// We used to return PERMISSION_DENIED only for error messages containing
// the string 'canceled by the user'. However, Windows internationalizes
// error messages (issue 96) so now we must assume all errors here are
// permission errors. This seems reasonable, given that we already run the
// user's command in a subshell.
if (error) return end(new Error(PERMISSION_DENIED));
end();
}
);
child.stdin.end(); // Otherwise PowerShell waits indefinitely on Windows 7.
Expand Down

0 comments on commit 8d02007

Please sign in to comment.