How to use is-root - 3 common examples

To help you get started, we’ve selected a few is-root examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xcodebuild / dns-proxy-https / src / index.js View on Github external
synopsis: [
    '$ sudo dns-proxy-https -s 127.0.0.1 -p 1081',
    '$ sudo dns-proxy-https -s 127.0.0.1 -p 1081 -f 114.114.114.114 -t 500000',
    '$ sudo dns-proxy-https -s 127.0.0.1 -p 1081 -w whitelist.txt'
  ],
  footer: 'Project home: [dns-proxy-https]{https://github.com/CodeFalling/dns-proxy-https}'
};

let option = cli.parse();

console.log(cli.getUsage(app));

// help end

// check sudo
if (!isRoot()) {
  throw new Error('Please run dns-proxy-https with sudo!');
}

// read whitelist if existed
let whitelist = [];
if (option.whitelist_file) {
  fs.readFile(option.whitelist_file, 'utf8', function (err, data) {
    if (err) {
      winston.info(err);
      return;
    }
    whitelist = data.split('\n').filter(line => {
      return line[0] !== '#'; // ignore comment
    });
  });
}
github umijs / umi / packages / af-webpack / src / choosePort.js View on Github external
new Promise(resolve => {
        if (port === defaultPort) {
          return resolve(port);
        }
        const message =
          process.platform !== 'win32' && defaultPort < 1024 && !isRoot()
            ? `Admin permissions are required to run a server on a port below 1024.`
            : `Something is already running on port ${defaultPort}.`;
        if (isInteractive) {
          clearConsole();
          const existingProcess = getProcessForPort(defaultPort);
          const question = {
            type: 'confirm',
            name: 'shouldChangePort',
            message: `${chalk.yellow(
              `message${
                existingProcess // eslint-disable-line
                  ? ` Probably:\n  ${existingProcess}`
                  : ''
              }`,
            )}\n\nWould you like to run the app on another port instead?`,
            default: true,
github viewstools / morph / runCraWebpackDevServerUtils.js View on Github external
new Promise(resolve => {
        if (port === defaultPort) {
          return resolve(port)
        }
        const message =
          process.platform !== 'win32' && defaultPort < 1024 && !isRoot()
            ? `Admin permissions are required to run a server on a port below 1024.`
            : `Something is already running on port ${defaultPort}.`
        if (isInteractive) {
          clearConsole()
          const existingProcess = getProcessForPort(defaultPort)
          const question = {
            type: 'confirm',
            name: 'shouldChangePort',
            message:
              chalk.yellow(
                message +
                  `${existingProcess ? ` Probably:\n  ${existingProcess}` : ''}`
              ) + '\n\nWould you like to run the app on another port instead?',
            default: true,
          }
          inquirer.prompt(question).then(answer => {

is-root

Check if the process is running as root user, for example, one started with `sudo`

MIT
Latest version published 4 years ago

Package Health Score

70 / 100
Full package analysis

Popular is-root functions