Skip to content

Commit

Permalink
Merge pull request #166 from unexpectedjs/tech/asyncApplyFixes
Browse files Browse the repository at this point in the history
Make `applyFixes` async to avoid `prettyMaybe.sync`
  • Loading branch information
papandreou authored Jan 23, 2024
2 parents 164bcc6 + 46c0912 commit e15e461
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"singleQuote": true
"singleQuote": true,
"trailingComma": "es5"
}
4 changes: 2 additions & 2 deletions lib/applyFixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function fixUnassessed(
return fixes;
}

function applyFixes(fixes) {
async function applyFixes(fixes) {
const fixesByFileName = {};
let numFixedExpects = 0;
for (const fix of fixes) {
Expand Down Expand Up @@ -254,7 +254,7 @@ function applyFixes(fixes) {
if (
!/^(?:0|false|off|no)$/.test(process.env.UNEXPECTED_SNAPSHOT_PRETTIER)
) {
fixedCode = prettyMaybe.sync(fileName, fixedCode, {
fixedCode = await prettyMaybe(fileName, fixedCode, {
requireConfig: false,
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/unexpected-snapshot-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function ensureAfterHookIsRegistered() {
afterBlockRegistered = true;
after(async function () {
const { numFixedExpects, fixedSourceTextByFileName } =
applyFixes(topLevelFixes);
await applyFixes(topLevelFixes);

const fileNames = Object.keys(fixedSourceTextByFileName);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"mocha": "^8.0.1",
"nyc": "^15.0.0",
"offline-github-changelog": "^2.0.0",
"prettier": "~2.5.0",
"prettier": "~3.2.4",
"rollup": "^2.0.3",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-json": "^4.0.0",
Expand Down

0 comments on commit e15e461

Please sign in to comment.