1 | #!/usr/bin/env node
|
2 | const path = require('path')
|
3 | const spawn = require('cross-spawn')
|
4 | const yargs = require('yargs')
|
5 | const pkg = require('./package')
|
6 |
|
7 | const 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 |
|
23 | if (cli.templateVersion) {
|
24 | console.log(`template-vue@${require('template-vue/package').version}`)
|
25 | process.exit()
|
26 | }
|
27 |
|
28 | if (cli.saoVersion) {
|
29 | console.log(`sao@${require('sao/package').version}`)
|
30 | process.exit()
|
31 | }
|
32 |
|
33 | const sao = require.resolve('sao/bin/sao')
|
34 |
|
35 | const argv = process.argv.slice(2)
|
36 | const templatePath = path.dirname(require.resolve('template-vue/package'))
|
37 | argv.unshift(templatePath)
|
38 |
|
39 |
|
40 | spawn.sync(sao, argv, { stdio: 'inherit' })
|