Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit d2917a9

Browse files
jamesgeorge007clarkdo
authored andcommitted
feat(chore): included a dedicated option to show up envinfo (#272)
1 parent 5738186 commit d2917a9

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

cli.js

+20
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,36 @@ const path = require('path')
33
const sao = require('sao')
44
const cac = require('cac')
55
const chalk = require('chalk')
6+
const envinfo = require('envinfo')
67
const { version } = require('./package.json')
78

89
const generator = path.resolve(__dirname, './')
910

1011
const cli = cac('create-nuxt-app')
1112

13+
const showEnvInfo = async () => {
14+
console.log(chalk.bold('\nEnvironment Info:'))
15+
const result = await envinfo
16+
.run({
17+
System: ['OS', 'CPU'],
18+
Binaries: ['Node', 'Yarn', 'npm'],
19+
Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'],
20+
npmGlobalPackages: ['nuxt', 'create-nuxt-app']
21+
})
22+
console.log(result)
23+
process.exit(1)
24+
}
25+
1226
cli
1327
.command('[out-dir] [options]', 'Generate in a custom directory or current directory')
1428
.option('--edge', 'To install `nuxt-edge` instead of `nuxt`')
29+
.option('--info', 'Print out debugging information relating to the local environment')
1530
.action((outDir = '.') => {
31+
const hasInfoArg = process.argv.slice(2)[0] === '--info'
32+
if (hasInfoArg) {
33+
return showEnvInfo()
34+
}
35+
console.log()
1636
console.log(chalk`{cyan create-nuxt-app v${version}}`)
1737
console.log(chalk`✨ Generating Nuxt.js project in {cyan ${outDir}}`)
1838

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"cac": "^6.5.2",
2323
"chalk": "^2.4.2",
2424
"cross-spawn": "^6.0.5",
25+
"envinfo": "^7.3.1",
2526
"glob": "^7.1.3",
2627
"lodash": "^4.17.11",
2728
"sao": "^1.6.1",

0 commit comments

Comments
 (0)