Skip to content

Commit

Permalink
fix(migrate): run migrations serially (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey authored Jan 3, 2019
1 parent 9000add commit 6449d28
Showing 1 changed file with 31 additions and 34 deletions.
65 changes: 31 additions & 34 deletions packages/migrate/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,40 +54,37 @@ export default async function(options) {
fileNames: {}
};

await Promise.all(
files.map(async file => {
const basename = path.basename(file);
if (basename.endsWith(".marko")) {
const prettyPrintOptions = {
syntax: options.syntax,
maxLen: options.maxLen,
noSemi: options.noSemi,
singleQuote: options.singleQuote,
filename: file
};
const migrateHelper = new MigrateHelper(options.prompt);
const add = migrateOptions =>
addMigration(migrateHelper, migrateOptions);
const source = await fs.readFile(file, "utf-8");
const ast = markoCompiler.parse(source, file, {
onContext(ctx) {
prettyPrintOptions.context = ctx;
ctx.addMigration = add;
addDefaultMigrations(ctx, results);
},
migrate: true,
raw: true
});

await runAutoMigrations(migrateHelper);

results.fileContents[file] = markoPrettyprint.prettyPrintAST(
ast,
prettyPrintOptions
);
}
})
);
for (const file of files) {
const basename = path.basename(file);
if (basename.endsWith(".marko")) {
const prettyPrintOptions = {
syntax: options.syntax,
maxLen: options.maxLen,
noSemi: options.noSemi,
singleQuote: options.singleQuote,
filename: file
};
const migrateHelper = new MigrateHelper(options.prompt);
const add = migrateOptions => addMigration(migrateHelper, migrateOptions);
const source = await fs.readFile(file, "utf-8");
const ast = markoCompiler.parse(source, file, {
onContext(ctx) {
prettyPrintOptions.context = ctx;
ctx.addMigration = add;
addDefaultMigrations(ctx, results);
},
migrate: true,
raw: true
});

await runAutoMigrations(migrateHelper);

results.fileContents[file] = markoPrettyprint.prettyPrintAST(
ast,
prettyPrintOptions
);
}
}

return results;
}
Expand Down

0 comments on commit 6449d28

Please sign in to comment.