Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing the result of fs.stat to child_process.spawn #53

Open
eriklarko opened this issue Jul 13, 2017 · 1 comment
Open

Passing the result of fs.stat to child_process.spawn #53

eriklarko opened this issue Jul 13, 2017 · 1 comment

Comments

@eriklarko
Copy link

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.

Am I using the library wrong?

@eriklarko
Copy link
Author

Ah, I did not see #41 :) I'll patch that in then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants