Skip to content

Instantly share code, notes, and snippets.

@sulliwane
Last active July 13, 2018 10:13
Show Gist options
  • Save sulliwane/a2817f02e1bd8f0686098ef04f1c3625 to your computer and use it in GitHub Desktop.
Save sulliwane/a2817f02e1bd8f0686098ef04f1c3625 to your computer and use it in GitHub Desktop.

Ora output is not written to stdout.txt:

node main.js sub show > stdout.txt
const cli = require('commander');
const ora = require('ora');
const sleep = ms => new Promise(res => setTimeout(res, ms));
cli
.command('show')
.description('log some text to stdout')
.action(async (cmd) => {
await sleep(2000);
console.log('log text');
ora().succeed('spinner text');
})
cli.parse(process.argv);
const cli = require('commander');
async function main() {
cli.command('sub', 'subcommand');
cli.parse(process.argv);
}
main();
{
"name": "cli-redirect",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"commander": "^2.15.1",
"ora": "^2.1.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment