Skip to content

Commit edd316b

Browse files
committed
fix: do not use sudo if it is doesn't exist (e.g. in Docker)
1 parent 6e4b02a commit edd316b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,17 @@ export const spawning = (Sys.spawning = function (
242242

243243
if (sudo) {
244244
argument = [command].concat(argument);
245-
command = isWindows() ? join(__dirname, 'bin', 'sudo.bat') : 'sudo';
245+
246+
// sudo
247+
if (isWindows()) {
248+
command = join(__dirname, 'bin', 'sudo.bat');
249+
} else {
250+
if (where('sudo') !== null) {
251+
command = 'sudo';
252+
} else {
253+
command = '';
254+
}
255+
}
246256
}
247257

248258
const spawned = spawn(command, argument, options);

0 commit comments

Comments
 (0)