b4a83891fb | ||
---|---|---|
.. | ||
src | ||
README.md | ||
package.json | ||
tsconfig.json |
README.md
root-tools
Tools for working with root and sudo such as executing command as root, detecting root, etc.
Install
npm install --save root-tools
Usage
isSudo
(function)
Detect if sudo is available and the user has root privileges
returns: boolean
isRoot
(function)
Detect if the process has root privileges
returns: boolean
prependSudo
(function)
Prepend sudo
to the command if sudo is available
Parameters:
- command (
string
)
returns: string
execRootSync
(function)
Execute a command as root if sudo is available. Otherwise executes the command normally without sudo.
Parameters:
- program (
string
) - The program to spawn - args (
string[]
) - The command arguments - execOptions (
execa.SyncOptions
) - The options passed toexeca
. Defaults to{ stdio: "inherit" }
returns: execa.ExecaSyncReturnValue
execRoot
(function)
Asynchronously execute a command as root if sudo is available. Otherwise executes the command normally without sudo.
Parameters:
- program (
string
) - The program to spawn - args (
string[]
) - The command arguments - execOptions (
execa.Options
) - The options passed toexeca
. Defaults to{ stdio: "inherit" }
returns: execa.ExecaChildProcess
🤝 Contributing
You can sponsor my work here:
https://github.com/sponsors/aminya
Pull requests, issues and feature requests are welcome. See the Contributing guide.