File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -162,9 +162,13 @@ var initInquirer = require('../lib/initialize');
162
162
if ( argv . init ) {
163
163
initInquirer ( argv . _ ) ;
164
164
} else if ( argv . migrate ) {
165
- const dummyConfigLoc = require . resolve ( path . join ( process . cwd ( ) , 'example/webpack.config.js' ) ) ;
166
- const outputConfigLoc = path . join ( process . cwd ( ) , 'example/neo-webpack.config.js' ) ;
167
- require ( '../lib/migrate.js' ) ( dummyConfigLoc , outputConfigLoc ) ;
165
+ const filePaths = argv . _ ;
166
+ if ( ! filePaths . length ) {
167
+ throw new Error ( 'Please specify a path to your webpack config' ) ;
168
+ }
169
+ const inputConfigPath = path . resolve ( process . cwd ( ) , filePaths [ 0 ] ) ;
170
+
171
+ require ( '../lib/migrate.js' ) ( inputConfigPath , inputConfigPath ) ;
168
172
} else {
169
173
processOptions ( yargs , argv ) ;
170
174
}
Original file line number Diff line number Diff line change @@ -4,8 +4,8 @@ const chalk = require('chalk');
4
4
const transform = require ( './transformations' ) . transform ;
5
5
const inquirer = require ( 'inquirer' ) ;
6
6
7
- module . exports = ( currentConfigLoc , outputConfigLoc ) => {
8
- let currentConfig = fs . readFileSync ( currentConfigLoc , 'utf8' ) ;
7
+ module . exports = ( currentConfigPath , outputConfigPath ) => {
8
+ let currentConfig = fs . readFileSync ( currentConfigPath , 'utf8' ) ;
9
9
const outputConfig = transform ( currentConfig ) ;
10
10
const diffOutput = diff . diffLines ( currentConfig , outputConfig ) ;
11
11
diffOutput . map ( diffLine => {
@@ -27,8 +27,8 @@ module.exports = (currentConfigLoc, outputConfigLoc) => {
27
27
. then ( answers => {
28
28
if ( answers [ 'confirmMigration' ] ) {
29
29
// TODO validate the config
30
- fs . writeFileSync ( outputConfigLoc , outputConfig , 'utf8' ) ;
31
- process . stdout . write ( chalk . green ( `Congratulations! Your new webpack v2 config file is at ${ outputConfigLoc } ` ) ) ;
30
+ fs . writeFileSync ( outputConfigPath , outputConfig , 'utf8' ) ;
31
+ process . stdout . write ( chalk . green ( `Congratulations! Your new webpack v2 config file is at ${ outputConfigPath } ` ) ) ;
32
32
} else {
33
33
process . stdout . write ( chalk . yellow ( 'Migration aborted' ) ) ;
34
34
}
You can’t perform that action at this time.
0 commit comments