Last active
March 1, 2018 21:51
-
-
Save samyranavela/2d3880ab9acdaa884d07da2ec280c9ef to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Show hidden characters
| { | |
| "presets": ["env"] | |
| } |
This file contains hidden or 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 | |
| 'use strict'; | |
| require("babel-register"); | |
| require('../src/index.js'); |
This file contains hidden or 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
| { | |
| "name": "hello", | |
| "version": "1.0.0", | |
| "description": "", | |
| "main": "src/index.js", | |
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1" | |
| }, | |
| "author": "", | |
| "license": "ISC", | |
| "bin": { | |
| "hello": "bin/hello.js" | |
| }, | |
| "dependencies": { | |
| "chalk": "^2.3.1", | |
| "commander": "^2.14.1" | |
| }, | |
| "devDependencies": { | |
| "babel-cli": "^6.26.0", | |
| "babel-preset-env": "^1.6.1", | |
| "babel-register": "^6.26.0" | |
| } | |
| } |
This file contains hidden or 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
| import program from 'commander'; | |
| import chalk from 'chalk'; | |
| const types = (args) => { | |
| return args.split(','); | |
| } | |
| program | |
| .version('0.1.0') | |
| .arguments('<name>') | |
| .option('-t, --type <type>', 'Types', types, []) | |
| .action((name, options) => { | |
| console.log(chalk.blue('Hello %s'), name); | |
| if (options.type.length) | |
| console.log(options.type); | |
| }) | |
| .parse(process.argv); | |
| if (!program.args.length) program.help(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment