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

Version 4 example in ES5 #63

Open
duongtungls opened this issue May 19, 2018 · 1 comment
Open

Version 4 example in ES5 #63

duongtungls opened this issue May 19, 2018 · 1 comment

Comments

@duongtungls
Copy link

duongtungls commented May 19, 2018

Hello, I try to convert your example from ES6 to ES5, but it's not work.

import Sudoer from 'electron-sudo';

let options = {name: 'electron sudo application'},
    sudoer = new Sudoer(options);

/* Spawn subprocess behavior */
let cp = await sudoer.spawn(
  'echo', ['$PARAM'], {env: {PARAM: 'VALUE'}}
);
cp.on('close', () => {
  /*
    cp.output.stdout (Buffer)
    cp.output.stderr (Buffer)
  */
});

/* Exec subprocess behavior */
let result = await sudoer.exec(
  'echo $PARAM', {env: {PARAM: 'VALUE'}}
);
/* result is Buffer with mixed (both stdout

And I tried with Vanila JS also

  var Sudoer = require('electron-sudo').default;
  let options = {name: 'electron sudo application'};
  var sudoer = new Sudoer(options);
  sudoer.spawn('echo', ['$PARAM'], {env: {PARAM: 'VALUE'}}).then(function (cp) {

      cp.output.stdout (Buffer)
      cp.output.stderr (Buffer)

  });

But got error Unhandled rejection TypeError: cp.output.stdout is not a function

Thanks

@nabil1337
Copy link

nabil1337 commented May 25, 2018

The (Buffer) part in

  /*
    cp.output.stdout (Buffer)
    cp.output.stderr (Buffer)
  */

was used to indicate that the type of cp.output.stdout and cp.output.stderr is Buffer. It is not valid/working JS here, therefore you can't just uncomment it without getting an error. You are trying to call it.

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

No branches or pull requests

2 participants