setup-cpp/packages/root-tools
Amin Yahyaabadi a0ead740f7 fix: fix the root-tools folder name 2022-08-07 19:27:05 -07:00
..
src fix: fix the root-tools folder name 2022-08-07 19:27:05 -07:00
README.md fix: fix the root-tools folder name 2022-08-07 19:27:05 -07:00
package.json fix: fix the root-tools folder name 2022-08-07 19:27:05 -07:00
tsconfig.json fix: fix the root-tools folder name 2022-08-07 19:27:05 -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.