From 217342f061afb725650a4192b939c2b58b83b9ff Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Mon, 27 Mar 2023 15:18:11 -0400 Subject: [PATCH] fix windows --- .../test/units/content-collections/frontmatter.test.js | 3 ++- packages/astro/test/units/test-utils.js | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/astro/test/units/content-collections/frontmatter.test.js b/packages/astro/test/units/content-collections/frontmatter.test.js index a4ec108275fa..d4a9f1eceef4 100644 --- a/packages/astro/test/units/content-collections/frontmatter.test.js +++ b/packages/astro/test/units/content-collections/frontmatter.test.js @@ -1,6 +1,7 @@ import { fileURLToPath } from 'node:url'; import nodeFS from 'node:fs'; import path from 'node:path'; +import slash from 'slash'; import { runInContainer } from '../../../dist/core/dev/index.js'; import { attachContentServerListeners } from '../../../dist/content/index.js'; @@ -10,7 +11,7 @@ const root = new URL('../../fixtures/alias/', import.meta.url); function getTypesDts() { const typesdtsURL = new URL('../../../src/content/template/types.d.ts', import.meta.url); - const relpath = path.relative(fileURLToPath(root), fileURLToPath(typesdtsURL)); + const relpath = slash(path.relative(fileURLToPath(root), fileURLToPath(typesdtsURL))); return { [relpath]: nodeFS.readFileSync(typesdtsURL, 'utf-8') }; diff --git a/packages/astro/test/units/test-utils.js b/packages/astro/test/units/test-utils.js index f142fceaf6b3..68a86d47564c 100644 --- a/packages/astro/test/units/test-utils.js +++ b/packages/astro/test/units/test-utils.js @@ -3,7 +3,7 @@ import { Volume } from 'memfs'; import httpMocks from 'node-mocks-http'; import realFS from 'node:fs'; import npath from 'path'; -import { fileURLToPath } from 'url'; +import { fileURLToPath, pathToFileURL } from 'url'; import { unixify } from './correct-path.js'; class VirtualVolume extends Volume { @@ -26,6 +26,10 @@ class VirtualVolume extends Volume { return npath.posix.join(this.#root, pth); } + readFile(p, ...args) { + return super.readFile(this.#forcePath(p), ...args); + } + existsSync(p) { return super.existsSync(this.#forcePath(p)); }