@@ -30,7 +30,7 @@ exports.bootstrap = function ({
30
30
plugins,
31
31
theme
32
32
} = { } ) {
33
- const { path } = require ( '@vuepress/shared-utils' )
33
+ const { path, logger , env } = require ( '@vuepress/shared-utils' )
34
34
const { dev, build, eject } = require ( '@vuepress/core' )
35
35
36
36
program
@@ -46,21 +46,56 @@ exports.bootstrap = function ({
46
46
. option ( '-c, --cache <cache>' , 'set the directory of cache' )
47
47
. option ( '--no-cache' , 'clean the cache before build' )
48
48
. option ( '--debug' , 'start development server in debug mode' )
49
- . action ( ( dir = '.' , { host, port, debug, temp, cache } ) => {
50
- wrapCommand ( dev ) ( path . resolve ( dir ) , { host, port, debug, temp, cache, plugins, theme } )
49
+ . option ( '--silent' , 'start development server in silent mode' )
50
+ . action ( ( sourceDir = '.' , {
51
+ host,
52
+ port,
53
+ debug,
54
+ temp,
55
+ cache,
56
+ silent
57
+ } ) => {
58
+ logger . setOptions ( { logLevel : silent ? 1 : debug ? 4 : 3 } )
59
+ env . setOptions ( { isDebug : debug , isTest : process . env . NODE_ENV === 'test' } )
60
+
61
+ wrapCommand ( dev ) ( path . resolve ( sourceDir ) , {
62
+ host,
63
+ port,
64
+ temp,
65
+ cache,
66
+ plugins,
67
+ theme
68
+ } )
51
69
} )
52
70
53
71
program
54
72
. command ( 'build [targetDir]' )
55
73
. description ( 'build dir as static site' )
56
- . option ( '-d, --dest <outDir >' , 'specify build output dir (default: .vuepress/dist)' )
74
+ . option ( '-d, --dest <dest >' , 'specify build output dir (default: .vuepress/dist)' )
57
75
. option ( '-t, --temp <temp>' , 'set the directory of the temporary file' )
58
76
. option ( '-c, --cache <cache>' , 'set the directory of cache' )
59
77
. option ( '--no-cache' , 'clean the cache before build' )
60
78
. option ( '--debug' , 'build in development mode for debugging' )
61
- . action ( ( dir = '.' , { debug, dest, temp, cache } ) => {
62
- const outDir = dest ? path . resolve ( dest ) : null
63
- wrapCommand ( build ) ( path . resolve ( dir ) , { debug, outDir, plugins, theme, temp, cache } )
79
+ . option ( '--silent' , 'build static site in silent mode' )
80
+ . action ( ( sourceDir , {
81
+ debug,
82
+ dest,
83
+ temp,
84
+ cache,
85
+ silent
86
+ } ) => {
87
+ logger . setOptions ( { logLevel : silent ? 1 : debug ? 4 : 3 } )
88
+ env . setOptions ( { isDebug : debug , isTest : process . env . NODE_ENV === 'test' } )
89
+
90
+ wrapCommand ( build ) ( path . resolve ( sourceDir ) , {
91
+ debug,
92
+ dest,
93
+ plugins,
94
+ theme,
95
+ temp,
96
+ cache,
97
+ silent
98
+ } )
64
99
} )
65
100
66
101
program
0 commit comments