diff --git a/compiler/packages/snap/src/compiler.ts b/compiler/packages/snap/src/compiler.ts index 3210e235c761c..5c9d841dcffe6 100644 --- a/compiler/packages/snap/src/compiler.ts +++ b/compiler/packages/snap/src/compiler.ts @@ -270,8 +270,11 @@ function getEvaluatorPresets( ); return presets; } -function format(inputCode: string, language: "typescript" | "flow"): string { - return prettier.format(inputCode, { +async function format( + inputCode: string, + language: "typescript" | "flow", +): Promise { + return await prettier.format(inputCode, { semi: true, parser: language === "typescript" ? "babel-ts" : "flow", }); @@ -287,13 +290,15 @@ export type TransformResult = { } | null; }; -export function transformFixtureInput( +export async function transformFixtureInput( input: string, fixturePath: string, parseConfigPragmaFn: typeof ParseConfigPragma, plugin: BabelCore.PluginObj, includeEvaluator: boolean, -): { kind: "ok"; value: TransformResult } | { kind: "err"; msg: string } { +): Promise< + { kind: "ok"; value: TransformResult } | { kind: "err"; msg: string } +> { // Extract the first line to quickly check for custom test directives const firstLine = input.substring(0, input.indexOf("\n")); @@ -400,7 +405,7 @@ export function transformFixtureInput( return { kind: "ok", value: { - forgetOutput: format(forgetOutput, language), + forgetOutput: await format(forgetOutput, language), evaluatorCode, }, }; diff --git a/compiler/packages/snap/src/runner-worker.ts b/compiler/packages/snap/src/runner-worker.ts index ac7ed5af7c4da..e42bc6a236e2a 100644 --- a/compiler/packages/snap/src/runner-worker.ts +++ b/compiler/packages/snap/src/runner-worker.ts @@ -33,16 +33,16 @@ export function clearRequireCache() { }); } -function compile( +async function compile( input: string, fixturePath: string, compilerVersion: number, shouldLog: boolean, includeEvaluator: boolean, -): { +): Promise<{ error: string | null; compileResult: TransformResult | null; -} { +}> { const seenConsoleErrors: Array = []; console.error = (...messages: Array) => { seenConsoleErrors.push(...messages); @@ -68,7 +68,7 @@ function compile( // only try logging if we filtered out all but one fixture, // since console log order is non-deterministic toggleLogging(shouldLog); - const result = transformFixtureInput( + const result = await transformFixtureInput( input, fixturePath, parseConfigPragma, @@ -147,7 +147,7 @@ export async function transformFixture( unexpectedError: null, }; } - const { compileResult, error } = compile( + const { compileResult, error } = await compile( input, fixture.fixturePath, compilerVersion,