From 5c09894f8580eb863111803311b4d9ea328756aa Mon Sep 17 00:00:00 2001 From: Julien Huang Date: Sun, 16 Jun 2024 16:26:47 +0200 Subject: [PATCH 1/2] test(schema): normalize snapshot paths for windows (#27654) --- packages/schema/test/folder-structure.spec.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/schema/test/folder-structure.spec.ts b/packages/schema/test/folder-structure.spec.ts index 3ea1e70c8b..1f59c8f908 100644 --- a/packages/schema/test/folder-structure.spec.ts +++ b/packages/schema/test/folder-structure.spec.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from 'vitest' import { applyDefaults } from 'untyped' +import { normalize } from 'pathe' import { NuxtConfigSchema } from '../src' import type { NuxtOptions } from '../src' @@ -75,7 +76,9 @@ describe('nuxt folder structure', () => { }) function getDirs (options: NuxtOptions) { - const stripRoot = (dir: string) => dir.replace(process.cwd(), '') + const stripRoot = (dir: string) => { + return normalize(dir).replace(normalize(process.cwd()), '') + } return { rootDir: stripRoot(options.rootDir), serverDir: stripRoot(options.serverDir), From 0850a2f2775958f7684fdc8d8e7f84117aee3b7c Mon Sep 17 00:00:00 2001 From: Julien Huang Date: Sun, 16 Jun 2024 16:27:08 +0200 Subject: [PATCH 2/2] test(nuxt): normalize paths for windows (#27653) --- packages/nuxt/test/components-transform.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/nuxt/test/components-transform.test.ts b/packages/nuxt/test/components-transform.test.ts index e1a6a8a1e5..76859ef621 100644 --- a/packages/nuxt/test/components-transform.test.ts +++ b/packages/nuxt/test/components-transform.test.ts @@ -2,6 +2,7 @@ import { fileURLToPath } from 'node:url' import { describe, expect, it } from 'vitest' import type { Component, Nuxt } from '@nuxt/schema' import { kebabCase } from 'scule' +import { normalize } from 'pathe' import { createTransformPlugin } from '../src/components/transform' @@ -92,7 +93,7 @@ function createTransformer (components: Component[], mode: 'client' | 'server' | return async (code: string, id: string) => { const result = await (plugin as any).transform!(code, id) - return (typeof result === 'string' ? result : result?.code)?.replaceAll(rootDir, '/') + return (typeof result === 'string' ? result : result?.code)?.replaceAll(normalize(rootDir), '/') } }