Skip to content

Commit a46edbb

Browse files
authored
fix: Use real paths from argvs instead of dummy hard-coded file (#65)
1 parent 6a4a62b commit a46edbb

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

bin/webpack.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,13 @@ var initInquirer = require('../lib/initialize');
162162
if(argv.init) {
163163
initInquirer(argv._);
164164
} 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);
168172
} else {
169173
processOptions(yargs,argv);
170174
}

lib/migrate.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const chalk = require('chalk');
44
const transform = require('./transformations').transform;
55
const inquirer = require('inquirer');
66

7-
module.exports = (currentConfigLoc, outputConfigLoc) => {
8-
let currentConfig = fs.readFileSync(currentConfigLoc, 'utf8');
7+
module.exports = (currentConfigPath, outputConfigPath) => {
8+
let currentConfig = fs.readFileSync(currentConfigPath, 'utf8');
99
const outputConfig = transform(currentConfig);
1010
const diffOutput = diff.diffLines(currentConfig, outputConfig);
1111
diffOutput.map(diffLine => {
@@ -27,8 +27,8 @@ module.exports = (currentConfigLoc, outputConfigLoc) => {
2727
.then(answers => {
2828
if (answers['confirmMigration']) {
2929
// 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}`));
3232
} else {
3333
process.stdout.write(chalk.yellow('Migration aborted'));
3434
}

0 commit comments

Comments
 (0)