INNER CODE UNIT · JavaScript

catchify

clinicjs/node-clinic · bin.js:257

function catchify (asyncFn) {
  return function (...args) {
    asyncFn(...args).catch((err) => {
      console.error(err.stack)
      process.exit(1)
    })
  }
}

function checkArgs (toolname, args, help, version) {
  if (args['--'] && args['--'].length >= 1 && !/^node(\.exe)?$/.test(path.basename(args['--'][0]))) {
    console.error(`Clinic.js must be called with a \`node\` command line: \`clinic ${toolname} -- node script.js\`\n`)

    printHelp(help, version)
    process.exit(1)
  }
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…