Last active
March 3, 2024 15:51
-
-
Save random42/28366cadf21b2aa4d7a322a0855e4f7b to your computer and use it in GitHub Desktop.
Node cli script template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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