Skip to content

Instantly share code, notes, and snippets.

@random42
Last active March 3, 2024 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save random42/28366cadf21b2aa4d7a322a0855e4f7b to your computer and use it in GitHub Desktop.
Save random42/28366cadf21b2aa4d7a322a0855e4f7b to your computer and use it in GitHub Desktop.
Node cli script template
#!/usr/bin/env node
const log = (...a) => console.error(...a)
const sleep = async (ms) => new Promise(res => setTimeout(res, ms))
const logUpdate = require('log-update').create(process.stderr, {showCursor: false})
const readJson = require('load-json-file')
const writeJson = require('write-json-file')
const inquirer = require('inquirer')
const clipboardy = require('clipboardy')
const { Transform, finished } = require('stream')
const JSONStream = require('JSONStream')
const chalk = require('chalk')
const meow = require('meow')
const assert = require('assert')
const cli = meow()
const { input, flags } = cli
const { red, blue, yellow } = chalk
run()
.then(exit)
.catch(abort)
async function run() {
}
function exit() {
process.exit(0)
}
function abort(err) {
err && log(err)
process.exit(1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment