Skip to content

Commit c7567ed

Browse files
committed
fix: unit tests on Windows
1 parent af205e2 commit c7567ed

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

packages/qwik/src/cli/add/update-files.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import fs from 'node:fs';
2-
import { extname, join } from 'node:path';
2+
import { extname, join, normalize } from 'node:path';
33
import type { FsUpdates, UpdateAppOptions } from '../types';
44
import { getPackageManager } from '../utils/utils';
55

@@ -22,12 +22,18 @@ export async function mergeIntegrationDir(
2222
const s = await fs.promises.stat(srcChildPath);
2323

2424
if (s.isDirectory()) {
25-
await mergeIntegrationDir(fileUpdates, opts, srcChildPath, destRootPath, alwaysInRoot);
25+
await mergeIntegrationDir(
26+
fileUpdates,
27+
opts,
28+
srcChildPath,
29+
normalize(destRootPath).replace(/\\/g, '/'),
30+
alwaysInRoot
31+
);
2632
} else if (s.isFile()) {
2733
const finalDestPath = getFinalDestPath(opts, destRootPath, destDir, destName, alwaysInRoot);
2834

2935
if (destName === 'package.json') {
30-
await mergePackageJsons(fileUpdates, srcChildPath, destRootPath);
36+
await mergePackageJsons(fileUpdates, srcChildPath, destRootPath.replace(/\\/g, '/'));
3137
} else if (destName === 'settings.json') {
3238
await mergeJsons(fileUpdates, srcChildPath, finalDestPath);
3339
} else if (destName === 'README.md') {
@@ -37,7 +43,7 @@ export async function mergeIntegrationDir(
3743
destName === '.prettierignore' ||
3844
destName === '.eslintignore'
3945
) {
40-
await mergeIgnoresFile(fileUpdates, srcChildPath, destRootPath);
46+
await mergeIgnoresFile(fileUpdates, srcChildPath, destRootPath.replace(/\\/g, '/'));
4147
} else if (ext === '.css') {
4248
await mergeCss(fileUpdates, srcChildPath, finalDestPath, opts);
4349
} else if (fs.existsSync(finalDestPath)) {
@@ -79,7 +85,8 @@ function getFinalDestPath(
7985
? destRootPath
8086
: destChildPath;
8187

82-
return finalDestPath;
88+
// Normalize path separators to forward slashes for cross-platform compatibility
89+
return normalize(finalDestPath).replace(/\\/g, '/');
8390
}
8491

8592
async function mergePackageJsons(fileUpdates: FsUpdates, srcPath: string, destPath: string) {

packages/qwik/src/optimizer/src/plugins/rollup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export function normalizeRollupOutputOptionsObject(
190190
const sanitized = relativePath
191191
.replace(/^(\.\.\/)+/, '')
192192
.replace(/^\/+/, '')
193-
.replace(/\//g, '-');
193+
.replace(/[\\/]/g, '-');
194194
return `build/${sanitized}.js`;
195195
};
196196
}

0 commit comments

Comments
 (0)