File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- var path = require ( 'path' ) ;
2- var defaultConfig = require ( path . resolve ( __dirname , '../__default__/default-config' ) ) ;
1+ const path = require ( 'path' ) ;
2+ const defaultConfig = require ( path . resolve ( __dirname , '../__default__/default-config' ) ) ;
3+ const chalk = require ( 'chalk' ) ;
34
45const configName = '.antdsite.js' ;
6+ let userConfig ;
57
68module . exports . getUserConfig = ( ) => {
7- var config = { } ;
9+ if ( userConfig ) return userConfig ;
10+
11+ let configPath ;
12+
813 try {
9- config = require ( path . resolve ( configName ) ) ;
14+ configPath = path . resolve ( configName ) ;
15+ userConfig = require ( configPath ) ;
1016 } catch ( error ) {
11- config = defaultConfig ;
17+ console . error (
18+ chalk . red (
19+ `[AntdSite]: Error when parsing ${ configName } at ${ configPath } , fallback to default config, the detail error is bellow:`
20+ )
21+ ) ;
22+ console . error ( error ) ;
23+ userConfig = defaultConfig ;
1224 }
1325
14- return config ;
26+ return userConfig ;
1527} ;
1628
1729function isObject ( receive ) {
@@ -35,7 +47,7 @@ function deepMerge(from, to) {
3547}
3648
3749module . exports . getFinalConfig = function ( ) {
38- var config = module . exports . getUserConfig ( ) ;
50+ const config = module . exports . getUserConfig ( ) ;
3951
4052 // merge with default config.
4153 const finalConfig = deepMerge ( config , defaultConfig ) ;
Original file line number Diff line number Diff line change 2424 "antd" : " ^3.20.1" ,
2525 "antd-tools" : " ^7.3.5" ,
2626 "axios" : " ^0.18.0" ,
27+ "chalk" : " 2.4.2" ,
2728 "change-case" : " ^3.1.0" ,
2829 "classnames" : " ^2.2.5" ,
2930 "docsearch.js" : " ^2.6.3" ,
You can’t perform that action at this time.
0 commit comments