From a66193547be4516637b5b5ac16ff14759c0b55a4 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Tue, 13 Mar 2018 17:43:44 -0400 Subject: [PATCH] test(Windows): fix failing tests on Windows --- src/cli/tests/cli.integration.spec.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cli/tests/cli.integration.spec.ts b/src/cli/tests/cli.integration.spec.ts index 0a490a4..f082246 100644 --- a/src/cli/tests/cli.integration.spec.ts +++ b/src/cli/tests/cli.integration.spec.ts @@ -108,16 +108,21 @@ async function hashAllTheThings( const hashes = await Promise.all(hashAll); return hashes.reduce<{ readonly [filename: string]: string }>( (acc, hash, i) => { - const trimmedFilePath = relative(buildDir, filePaths[i]); + const trimmedNormalizedFilePath = normalizePath(relative(buildDir, filePaths[i])); return { ...acc, - [trimmedFilePath]: hash + [trimmedNormalizedFilePath]: hash }; }, {} ); } +// On Windows, convert backslashes to forward slashes +function normalizePath(p: string) { + return process.platform === 'win32' ? p.replace(/\\/g, '/') : p; +} + test(`${ TestDirectories.one }: parses CLI arguments, handles default options`, async t => {