UNPKG

1.12 kBJavaScriptView Raw
1#!/usr/bin/env node
2const path = require('path')
3const spawn = require('cross-spawn')
4const yargs = require('yargs')
5const pkg = require('./package')
6
7const cli = yargs
8 .option('sao-version', {
9 desc: 'Display the version of package "sao"'
10 })
11 .option('template-version', {
12 desc: 'Display the version of package "template-vue"'
13 })
14 .example('$0 my-project', 'Generate a new project in "my-project" folder')
15 .epilogue(
16 'If you have any problems, do not hesitate to file an issue:\n https://github.com/egoist/create-vue-app/issues/new'
17 )
18 .alias('v', 'version')
19 .alias('h', 'help')
20 .version(pkg.version)
21 .help().argv
22
23if (cli.templateVersion) {
24 console.log(`template-vue@${require('template-vue/package').version}`)
25 process.exit()
26}
27
28if (cli.saoVersion) {
29 console.log(`sao@${require('sao/package').version}`)
30 process.exit()
31}
32
33const sao = require.resolve('sao/bin/sao')
34
35const argv = process.argv.slice(2)
36const templatePath = path.dirname(require.resolve('template-vue/package'))
37argv.unshift(templatePath)
38
39// Run `sao $template $argv`
40spawn.sync(sao, argv, { stdio: 'inherit' })