@@ -48,7 +48,7 @@ const DEFAULT_WEBPACK_CONFIG_FILENAME = 'webpack.config.js';
48
48
49
49
export function modifyHelperUtil (
50
50
action : string ,
51
- generator : typeof Generator ,
51
+ generator : Generator . GeneratorConstructor ,
52
52
configFile : string = DEFAULT_WEBPACK_CONFIG_FILENAME ,
53
53
packages ?: string [ ] ,
54
54
autoSetDefaults = false ,
@@ -91,11 +91,13 @@ export function modifyHelperUtil(
91
91
}
92
92
93
93
env . registerStub ( generator , generatorName ) ;
94
- env . run ( generatorName , {
95
- configFile,
96
- autoSetDefaults,
97
- } )
98
- . then ( ( ) : void => {
94
+ env . run (
95
+ generatorName ,
96
+ {
97
+ configFile,
98
+ autoSetDefaults,
99
+ } ,
100
+ ( ) => {
99
101
let configModule : object ;
100
102
let finalConfig : WebpackScaffoldObject = {
101
103
config : { } ,
@@ -128,29 +130,26 @@ export function modifyHelperUtil(
128
130
process . exitCode = 2 ;
129
131
}
130
132
131
- const transformConfig = Object . assign (
132
- {
133
- configFile : ! configPath ? null : fs . readFileSync ( configPath , 'utf8' ) ,
134
- configPath,
135
- } ,
136
- finalConfig ,
137
- ) as TransformConfig ;
138
- if ( finalConfig . usingDefaults && finalConfig . usingDefaults === true ) {
139
- const runCommand = getPackageManager ( ) === 'yarn' ? 'yarn build' : 'npm run build' ;
133
+ try {
134
+ const transformConfig = Object . assign (
135
+ {
136
+ configFile : ! configPath ? null : fs . readFileSync ( configPath , 'utf8' ) ,
137
+ configPath,
138
+ } ,
139
+ finalConfig ,
140
+ ) as TransformConfig ;
141
+ if ( finalConfig . usingDefaults && finalConfig . usingDefaults === true ) {
142
+ const runCommand = getPackageManager ( ) === 'yarn' ? 'yarn build' : 'npm run build' ;
140
143
141
- logger . log ( `\nYou can now run ${ green ( runCommand ) } to bundle your application!\n` ) ;
142
- }
144
+ logger . log ( `\nYou can now run ${ green ( runCommand ) } to bundle your application!\n` ) ;
145
+ }
143
146
144
- // scaffold webpack config file from using .yo-rc.json
145
- return runTransform ( transformConfig , 'init' , generateConfig ) ;
146
- } )
147
- . catch ( ( err ) : void => {
148
- logger . error (
149
- `
150
- Unexpected Error
151
- please file an issue here https://github.com/webpack/webpack-cli/issues/new?template=Bug_report.md
152
- ` ,
153
- ) ;
154
- logger . error ( err ) ;
155
- } ) ;
147
+ // scaffold webpack config file from using .yo-rc.json
148
+ return runTransform ( transformConfig , 'init' , generateConfig ) ;
149
+ } catch ( err ) {
150
+ logger . error ( err ) ;
151
+ process . exitCode = 2 ;
152
+ }
153
+ } ,
154
+ ) ;
156
155
}
0 commit comments