Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions bin/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,13 @@ var initInquirer = require('../lib/initialize');
if(argv.init) {
initInquirer(argv._);
} else if(argv.migrate) {
const dummyConfigLoc = require.resolve(path.join(process.cwd(), 'example/webpack.config.js'));
const outputConfigLoc = path.join(process.cwd(), 'example/neo-webpack.config.js');
require('../lib/migrate.js')(dummyConfigLoc, outputConfigLoc);
const filePaths = argv._;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

._argv is being used in init as well. Perhaps move the var outside the loop and pass the same variable to init too?

if (!filePaths.length) {
throw new Error('Please specify a path to your webpack config');
}
const inputConfigPath = path.resolve(process.cwd(), filePaths[0]);

require('../lib/migrate.js')(inputConfigPath, inputConfigPath);
} else {
processOptions(yargs,argv);
}
8 changes: 4 additions & 4 deletions lib/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const chalk = require('chalk');
const transform = require('./transformations').transform;
const inquirer = require('inquirer');

module.exports = (currentConfigLoc, outputConfigLoc) => {
let currentConfig = fs.readFileSync(currentConfigLoc, 'utf8');
module.exports = (currentConfigPath, outputConfigPath) => {
let currentConfig = fs.readFileSync(currentConfigPath, 'utf8');
const outputConfig = transform(currentConfig);
const diffOutput = diff.diffLines(currentConfig, outputConfig);
diffOutput.map(diffLine => {
Expand All @@ -27,8 +27,8 @@ module.exports = (currentConfigLoc, outputConfigLoc) => {
.then(answers => {
if (answers['confirmMigration']) {
// TODO validate the config
fs.writeFileSync(outputConfigLoc, outputConfig, 'utf8');
process.stdout.write(chalk.green(`Congratulations! Your new webpack v2 config file is at ${outputConfigLoc}`));
fs.writeFileSync(outputConfigPath, outputConfig, 'utf8');
process.stdout.write(chalk.green(`Congratulations! Your new webpack v2 config file is at ${outputConfigPath}`));
} else {
process.stdout.write(chalk.yellow('Migration aborted'));
}
Expand Down