@@ -6,25 +6,27 @@ const packageConfig = require('../package.json')
66const { cleanArgs } = require ( '../lib' )
77const boxPath = path . join ( process . cwd ( ) , 'box.config.js' )
88const chalk = require ( 'chalk' )
9+ const semver = require ( 'semver' )
910
10- const commandName = exports . commandName = [ ]
1111const commandStore = exports . commandStore = [ ]
1212let boxConfig = { }
1313if ( fs . existsSync ( boxPath ) ) boxConfig = require ( path . join ( process . cwd ( ) , 'box.config.js' ) ) ( )
1414let status = 'pending'
1515
16+ checkNodeVersionForWarning ( )
17+
1618program
1719 . usage ( '<command> [options]' )
1820 . version ( packageConfig . version )
1921
2022module . exports . injectCommand = function ( cmd ) {
2123 if ( status === 'done' ) return console . error ( '注册命令行时机已经是 done,请提前注册~' )
2224 if ( typeof cmd !== 'function' ) return console . error ( cmd , '必须是一个函数' )
23- cmd ( { program, boxConfig, commandName , commandStore, cleanArgs } )
25+ cmd ( { program, boxConfig, commandStore, cleanArgs } )
2426}
2527
2628module . exports . commandComplete = function ( ) {
27- commandValidate ( )
29+ // commandValidate()
2830 parse ( )
2931 status = 'done'
3032}
@@ -35,7 +37,7 @@ function parse() {
3537}
3638
3739function commandValidate ( ) {
38- if ( process . argv [ 2 ] && ! commandName . includes ( process . argv [ 2 ] ) ) {
40+ if ( process . argv [ 2 ] ) {
3941 console . log ( )
4042 console . log ( chalk . red ( ` 没有找到 ${ process . argv [ 2 ] } 命令` ) )
4143 console . log ( )
@@ -46,3 +48,12 @@ function commandValidate() {
4648 program . help ( )
4749 }
4850}
51+
52+ function checkNodeVersionForWarning ( ) {
53+ if ( semver . satisfies ( process . version , '10.x' ) ) {
54+ console . log ( chalk . red (
55+ `你正在用的 node 版本是:${ process . version } .\n` +
56+ '未来版本将不再支持 10.x 版本.\n'
57+ ) )
58+ }
59+ }
0 commit comments