diff --git a/index.js b/index.js index 25e765e..8103ae9 100644 --- a/index.js +++ b/index.js @@ -73,8 +73,10 @@ function initTools(callback) { */ function scanNetworks(callback, useSudo) { const cmd = scanner.cmdLine.split(" "); - const args = cmd.slice(1); - const child = spawn((useSudo ? "sudo " : "" ) + cmd[0], args, { stdio: ['ignore', 'pipe', 'pipe'], detached: true }); + let args = cmd.slice(1); + if(useSudo) + args.unshift(cmd[0]); + const child = spawn(useSudo ? "sudo" : cmd[0], args, { stdio: ['ignore', 'pipe', 'pipe'], detached: true }); child.on("error", (err) => callback(err, null) );