Skip to content

Commit

Permalink
feat: Add prettier for formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavithra K committed Mar 2, 2017
1 parent 4020043 commit 6aad5a8
Show file tree
Hide file tree
Showing 4 changed files with 4,681 additions and 4 deletions.
4 changes: 3 additions & 1 deletion bin/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,11 @@ if(argv.init) {
if (!filePaths.length) {
throw new Error('Please specify a path to your webpack config');
}
const outputConfigName = filePaths[1] || `${filePaths[0]}v2.js`;
const inputConfigPath = path.resolve(process.cwd(), filePaths[0]);
const outputConfigPath = path.resolve(process.cwd(), outputConfigName);

require('../lib/migrate.js')(inputConfigPath, inputConfigPath);
require('../lib/migrate.js')(inputConfigPath, outputConfigPath);
} else {
processOptions(yargs,argv);
}
4 changes: 2 additions & 2 deletions lib/transformations/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const jscodeshift = require('jscodeshift');

const prettier = require('prettier');
const loadersTransform = require('./loaders/loaders');
const resolveTransform = require('./resolve/resolve');
const removeJsonLoaderTransform = require('./removeJsonLoader/removeJsonLoader');
Expand Down Expand Up @@ -38,7 +38,7 @@ function transform(source, transforms, options) {
}, options);
transforms = transforms || Object.keys(transformations).map(k => transformations[k]);
transforms.forEach(f => f(jscodeshift, ast));
return ast.toSource(recastOptions);
return prettier.format(ast.toSource(recastOptions), {singleQuote: true, tabWidth: 2});
}

module.exports = {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"jscodeshift": "^0.3.30",
"loader-utils": "^0.2.16",
"lodash": "^4.17.4",
"recast": "git://github.com/kalcifer/recast.git#bug/allowbreak",
"prettier": "^0.20.0",
"recast": "^0.11.22",
"rx": "^4.1.0",
"supports-color": "^3.1.2",
"webpack": "^2.2.0-rc.0",
Expand Down
Loading

0 comments on commit 6aad5a8

Please sign in to comment.