Skip to content

Instantly share code, notes, and snippets.

@andrewimm
Created May 15, 2017 18:14
Show Gist options
  • Save andrewimm/e4ada24c6e81f3040917de00b714c360 to your computer and use it in GitHub Desktop.
Save andrewimm/e4ada24c6e81f3040917de00b714c360 to your computer and use it in GitHub Desktop.
yarn create package, if your CLI requires intercepting the arguments
#!/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'});
{
"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