How to use sudo-block - 1 common examples

To help you get started, we’ve selected a few sudo-block 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 miscord / miscord / src / bin / index.ts View on Github external
const outdated = 'Hey! Your version of Node.JS seems outdated. Minimum version required: v8.5.0, your version: ' + process.version
  if (!require('semver').gte(process.version, '8.5.0')) printAndExit(chalk.yellow(outdated))

  const args = getArgs()
  if (args.help) printAndExit(help)
  if (args.version) printAndExit(version)
  if (args.getPath) printAndExit(getConfigDir())

  const defaultMessage = chalk`
{red.bold Miscord should not be run with root permissions.}
If running without {bold sudo} doesn't work, you can either fix your permission problems or change where npm stores global packages by putting {bold ~/npm/bin} in your PATH and running:
{blue npm config set prefix ~/npm}
See: {underline https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md}
If you {underline really} need to run Miscord with {bold sudo}, add parameter {bold --runningWithSudoIsDangerous}.
`
  if (!args.runningWithSudoIsDangerous) sudoBlock(defaultMessage)

  fork(args.dataPath)

  let loginFailed = true

  cluster.on('message', (worker, message) => {
    if (message === 'login successful') loginFailed = false
  })

  cluster.on('exit', (worker, code, signal) => {
    logger.error(`Worker process ${worker.process.pid} died (${code}, ${signal}).`)
    // Code 0: exit
    // Code 1: error
    // Code 2: restart
    if ((Date.now() - lastRunTime.getTime()) < (2 * 1000)) {
      logger.fatal('Process crashed less than 2 seconds since the last launch, exiting.')

sudo-block

Block users from running your app with root permissions

MIT
Latest version published 8 months ago

Package Health Score

66 / 100
Full package analysis

Popular sudo-block functions