Skip to content

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

Description

@eriklarko

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?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions