setup-cpp/packages/sudo-tools
Amin Yahyaabadi 41bcd6a578 Revert "fix: do not assume that CI (e.g. Docker) is root"
This reverts commit 0d99c85e65.
2022-08-07 18:35:57 -07:00
..
src Revert "fix: do not assume that CI (e.g. Docker) is root" 2022-08-07 18:35:57 -07:00
README.md docs: automatically create the readme for the packages 2022-08-07 18:18:26 -07:00
package.json fix: rename sudo-tools to root-tools 2022-08-07 17:38:34 -07:00
tsconfig.json feat: add sudo-tools package 2022-08-07 17:18:49 -07:00

README.md

root-tools

Version License: Apache--2.0

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 to execa. 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 to execa. 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.