Created
May 15, 2017 18:14
-
-
Save andrewimm/e4ada24c6e81f3040917de00b714c360 to your computer and use it in GitHub Desktop.
yarn create package, if your CLI requires intercepting the arguments
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 | |
'use strict'; | |
const path = require('path'); | |
const child_process = require('child_process'); | |
const bin = path.resolve(__dirname, 'node_modules', '.bin', 'your-app-cli'); | |
const args = process.argv.slice(2); | |
// Modify the args between "yarn create" and your CLI, like adding a command | |
args.unshift('init'); | |
child_process.spawn(bin, args, {stdio: 'inherit'}); |
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
{ | |
"name": "create-your-app", | |
"bin": "./bin.js", | |
"dependencies": { | |
"your-app-cli": "*" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment