Skip to content

Commit

Permalink
use prettier at migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
evenstensberg committed Dec 17, 2017
1 parent 88aaaa2 commit 972d4cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/commands/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const inquirer = require("inquirer");
const PLazy = require("p-lazy");
const Listr = require("listr");

const runPrettier = require("../utils/run-prettier");

module.exports = function transformFile(
currentConfigPath,
outputConfigPath,
Expand Down Expand Up @@ -78,7 +80,7 @@ module.exports = function transformFile(
])
.then(answers => {
if (answers["confirmMigration"]) {
fs.writeFile(outputConfigPath, result, "utf8", err => {
runPrettier(outputConfigPath, result, err => {
if (err) {
throw err;
} else {
Expand Down
7 changes: 6 additions & 1 deletion lib/utils/run-prettier.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ const chalk = require("chalk");
* @returns fs - Writes a file at given location and prints messages accordingly
*/

module.exports = function runPrettier(outputPath, source) {
module.exports = function runPrettier(outputPath, source, cb) {
function validateConfig() {
let prettySource;
let error;
try {
prettySource = prettier.format(source, {
singleQuote: true,
Expand All @@ -31,6 +32,10 @@ module.exports = function runPrettier(outputPath, source) {
)
);
prettySource = source;
error = err;
}
if (cb) {
return cb(error);
}
return fs.writeFileSync(outputPath, prettySource, "utf8");
}
Expand Down

0 comments on commit 972d4cd

Please sign in to comment.