From 6e9e7b6f84ad6d0ce36b51fc39c47dc974e99bdf Mon Sep 17 00:00:00 2001 From: Joran Dirk Greef Date: Tue, 18 Jul 2017 15:18:16 +0200 Subject: [PATCH] readme: explicitly mention that no child process is returned --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ea07bc8..0b122b5 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,20 @@ var options = { name: 'Electron', icns: '/Applications/Electron.app/Contents/Resources/Electron.icns', // (optional) }; -sudo.exec('echo hello', options, function(error, stdout, stderr) {}); +sudo.exec('echo hello', options, + function(error, stdout, stderr) { + if (error) throw error; + console.log('stdout: ' + stdout); + } +); ``` `sudo-prompt` will use `process.title` as `options.name` if `options.name` is not provided. `options.name` must be alphanumeric only (spaces are supported) and at most 70 characters. Your command should not depend on any current working directory or environment variables in order to execute correctly, and you should take care to use absolute paths and not relative paths. +**`sudo-prompt.exec()` is different to `child-process.exec()` in that no child process is returned (due to platform and permissions constraints).** + ## Behavior On macOS, `sudo-prompt` should behave just like the `sudo` command in the shell. If your command does not work with the `sudo` command in the shell (perhaps because it uses `>` redirection to a restricted file), then it may not work with `sudo-prompt`. However, it is still possible to use sudo-prompt to get a privileged shell, [see this closed issue for more information](https://github.com/jorangreef/sudo-prompt/issues/1).