When I run the example in the README (without await) I get the following output:
/bin/sh: 1: [object: not found
The code in its entirety is:
import ElectronSudo from 'electron-sudo';
const options = {
name: 'YOLO'
};
const sudo = new ElectronSudo(options);
let p = sudo.spawn(
'echo', ['$PARAM'], {env: {PARAM: 'VALUE'}}
).then( () => {
p.on('close', () => {
console.log('stderr:', p.output.stderr.toString());
});
});
After poking around a little in the source code I found that the getBinary method of SudoerLinux returns the result from stat in src/lib/utils.js which is an fs.Stats object. This object is then passed directly to child_process.spawn which would explain the [object part of the error output.
Changing the getBinary method to return the path to the binary instead of the stat object seemed to fix it for me.
When I run the example in the README (without await) I get the following output:
The code in its entirety is:
After poking around a little in the source code I found that the
getBinary
method ofSudoerLinux
returns the result fromstat
insrc/lib/utils.js
which is an fs.Stats object. This object is then passed directly tochild_process.spawn
which would explain the[object
part of the error output.Changing the
getBinary
method to return the path to the binary instead of the stat object seemed to fix it for me.Am I using the library wrong?