From 73b17830d00660c382f39b369fe1267b7cbec739 Mon Sep 17 00:00:00 2001 From: Joran Dirk Greef Date: Wed, 5 Aug 2015 09:10:34 +0200 Subject: [PATCH] Update README.md --- README.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9fe52b1..4c8aff0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Sudo +## sudo-prompt Run a command using sudo, prompting the user with an OS dialog if necessary. Useful for background applications or native Electron apps that need sudo. @@ -6,16 +6,23 @@ Run a command using sudo, prompting the user with an OS dialog if necessary. Use Currently supports native OS dialog prompt on Mac OS X (patches welcome for Linux) and uses process.title as the name of the app requesting permission. -Sudo has no external dependencies and does not contain any native bindings. +sudo-prompt has no external dependencies and does not require any native bindings. + +## Installation +``` +npm install sudo-prompt +``` ## Usage Note: Your command should not start with the "sudo" prefix. ``` -// To run a command using sudo: +// To run a command using sudo-prompt: var sudo = require('sudo-prompt'); sudo.exec('echo hello', function(error) {}); // To update the sudo timestamp for the current user: +// This will extend any existing sudo session for a few more minutes. +// It will prompt to create a new session if there is no existing sudo session. sudo.touch(function(error) {}); // To use something other than process.title as the app name: @@ -23,5 +30,8 @@ sudo.touch(function(error) {}); sudo.setName('Your app name') ``` +## Behavior +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 will not work with sudo-prompt. However, it is still possible to use sudo-prompt to get a privileged shell, [see this issue for more information](https://github.com/jorangreef/sudo/issues/1). + ## Concurrency You can call `sudo.exec` and `sudo.touch` concurrently, Sudo will batch up permission requests into a single prompt.