From c2b3db23006c651987af6ac06655895dd6a33a67 Mon Sep 17 00:00:00 2001 From: Anton Gilgur Date: Thu, 21 Jul 2022 14:15:15 -0400 Subject: [PATCH] fix: don't duplicate type-only check on Windows (#385) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - gotta remember to normalize file names 🙃 - this fixes a failing test on Windows by fixing the underlying bug - refactor: improve normalization in errors.spec - normalize _all_ calls to `local`, instead of just one - this doesn't affect the tests, only the source code change does, but I added this first and it's better practice / test future-proofing --- __tests__/integration/errors.spec.ts | 4 ++-- src/index.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/__tests__/integration/errors.spec.ts b/__tests__/integration/errors.spec.ts index 0c6b638..f4be8b6 100644 --- a/__tests__/integration/errors.spec.ts +++ b/__tests__/integration/errors.spec.ts @@ -10,7 +10,7 @@ import * as helpers from "./helpers"; // increase timeout to 15s for whole file since CI occassionally timed out -- these are integration and cache tests, so longer timeout is warranted jest.setTimeout(15000); -const local = (x: string) => path.resolve(__dirname, x); +const local = (x: string) => normalize(path.resolve(__dirname, x)); const cacheRoot = local("__temp/errors/rpt2-cache"); // don't use the one in node_modules afterAll(async () => { @@ -20,7 +20,7 @@ afterAll(async () => { }); async function genBundle(relInput: string, extraOpts?: RPT2Options, onwarn?: Mock) { - const input = normalize(local(`fixtures/errors/${relInput}`)); + const input = local(`fixtures/errors/${relInput}`); return helpers.genBundle({ input, tsconfig: local("fixtures/errors/tsconfig.json"), diff --git a/src/index.ts b/src/index.ts index 03bc713..6ec64dd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -56,6 +56,7 @@ const typescript: PluginImpl = (options) => const typecheckFile = (id: string, snapshot: tsTypes.IScriptSnapshot, tcContext: IContext) => { + id = normalize(id); checkedFiles.add(id); // must come before print, as that could bail const diagnostics = getDiagnostics(id, snapshot);