diff --git a/.changeset/spicy-houses-fry.md b/.changeset/spicy-houses-fry.md new file mode 100644 index 000000000000..41f376a3546f --- /dev/null +++ b/.changeset/spicy-houses-fry.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Simplifies path operations of `astro sync` diff --git a/packages/astro/src/core/sync/write-files.ts b/packages/astro/src/core/sync/write-files.ts index 395bd54f2b12..62f2ccb21f99 100644 --- a/packages/astro/src/core/sync/write-files.ts +++ b/packages/astro/src/core/sync/write-files.ts @@ -2,11 +2,11 @@ import type fsMod from 'node:fs'; import { dirname, relative } from 'node:path'; import { fileURLToPath } from 'node:url'; import { bold } from 'kleur/colors'; -import { normalizePath } from 'vite'; import type { AstroSettings } from '../../@types/astro.js'; import { AstroError, AstroErrorData } from '../errors/index.js'; import type { Logger } from '../logger/core.js'; import { REFERENCE_FILE } from './constants.js'; +import { normalizePath } from 'vite'; export async function writeFiles(settings: AstroSettings, fs: typeof fsMod, logger: Logger) { try { @@ -27,7 +27,7 @@ function writeInjectedTypes(settings: AstroSettings, fs: typeof fsMod) { const references: Array = []; for (const { filename, content } of settings.injectedTypes) { - const filepath = normalizePath(fileURLToPath(new URL(filename, settings.dotAstroDir))); + const filepath = fileURLToPath(new URL(filename, settings.dotAstroDir)); fs.mkdirSync(dirname(filepath), { recursive: true }); fs.writeFileSync(filepath, content, 'utf-8'); references.push(normalizePath(relative(fileURLToPath(settings.dotAstroDir), filepath))); @@ -38,17 +38,15 @@ function writeInjectedTypes(settings: AstroSettings, fs: typeof fsMod) { fs.mkdirSync(settings.dotAstroDir, { recursive: true }); } fs.writeFileSync( - normalizePath(fileURLToPath(new URL(REFERENCE_FILE, settings.dotAstroDir))), + fileURLToPath(new URL(REFERENCE_FILE, settings.dotAstroDir)), astroDtsContent, 'utf-8', ); } async function setUpEnvTs(settings: AstroSettings, fs: typeof fsMod, logger: Logger) { - const envTsPath = normalizePath(fileURLToPath(new URL('env.d.ts', settings.config.srcDir))); - const envTsPathRelativetoRoot = normalizePath( - relative(fileURLToPath(settings.config.root), envTsPath), - ); + const envTsPath = fileURLToPath(new URL('env.d.ts', settings.config.srcDir)); + const envTsPathRelativetoRoot = relative(fileURLToPath(settings.config.root), envTsPath); const relativePath = normalizePath( relative( fileURLToPath(settings.config.srcDir), diff --git a/packages/astro/test/astro-sync.test.js b/packages/astro/test/astro-sync.test.js index dfe4755d1102..bb044574fe32 100644 --- a/packages/astro/test/astro-sync.test.js +++ b/packages/astro/test/astro-sync.test.js @@ -4,7 +4,6 @@ import * as fs from 'node:fs'; import { beforeEach, describe, it } from 'node:test'; import { fileURLToPath } from 'node:url'; import ts from 'typescript'; -import { normalizePath } from 'vite'; import { loadFixture } from './test-utils.js'; const createFixture = () => { @@ -16,8 +15,7 @@ const createFixture = () => { /** * @param {string} path */ - const getExpectedPath = (path) => - normalizePath(fileURLToPath(new URL(path, astroFixture.config.root))); + const getExpectedPath = (path) => fileURLToPath(new URL(path, astroFixture.config.root)); return { /** @param {string} root */ diff --git a/packages/astro/test/units/dev/collections-renderentry.test.js b/packages/astro/test/units/dev/collections-renderentry.test.js index 9441129a7cd4..082cd6b2f78b 100644 --- a/packages/astro/test/units/dev/collections-renderentry.test.js +++ b/packages/astro/test/units/dev/collections-renderentry.test.js @@ -1,5 +1,4 @@ import * as assert from 'node:assert/strict'; -import os from 'node:os'; import { describe, it } from 'node:test'; import { fileURLToPath } from 'node:url'; import * as cheerio from 'cheerio'; @@ -9,8 +8,6 @@ import { createFsWithFallback, createRequestAndResponse, runInContainer } from ' const root = new URL('../../fixtures/content/', import.meta.url); -const _describe = os.platform() === 'win32' ? describe.skip : describe; - /** @type {typeof runInContainer} */ async function runInContainerWithContentListeners(params, callback) { return await runInContainer(params, async (container) => { @@ -19,7 +16,7 @@ async function runInContainerWithContentListeners(params, callback) { }); } -_describe('Content Collections - render()', () => { +describe('Content Collections - render()', () => { it('can be called in a page component', async () => { const fs = createFsWithFallback( {