diff --git a/.changeset/fix-windows-path-separators.md b/.changeset/fix-windows-path-separators.md new file mode 100644 index 000000000..3fabc6d9f --- /dev/null +++ b/.changeset/fix-windows-path-separators.md @@ -0,0 +1,5 @@ +--- +"lingo.dev": patch +--- + +Fix CLI tests failing on Windows due to path separator differences diff --git a/packages/cli/src/cli/utils/buckets.ts b/packages/cli/src/cli/utils/buckets.ts index 962030c09..e7850e49a 100644 --- a/packages/cli/src/cli/utils/buckets.ts +++ b/packages/cli/src/cli/utils/buckets.ts @@ -175,8 +175,8 @@ function expandPlaceholderedGlob( const placeholderedPath = sourcePathChunks.join(path.sep); return placeholderedPath; }); - // return the placeholdered paths - return placeholderedPaths; + // return the placeholdered paths (normalized to forward slashes for cross-platform compatibility) + return placeholderedPaths.map(p => p.replace(/\\/g, "/")); } function resolveBucketItem(bucketItem: string | BucketItem): BucketItem { diff --git a/packages/cli/src/cli/utils/find-locale-paths.ts b/packages/cli/src/cli/utils/find-locale-paths.ts index d584e8205..cd552c513 100644 --- a/packages/cli/src/cli/utils/find-locale-paths.ts +++ b/packages/cli/src/cli/utils/find-locale-paths.ts @@ -95,7 +95,7 @@ function findLocaleFilesForFilename(fileName: string) { const localeFilesAndPatterns = localeFiles.map((file: string) => ({ file, - pattern: path.join(path.dirname(file), pattern), + pattern: path.join(path.dirname(file), pattern).replace(/\\/g, "/"), })); const grouppedFilesAndPatterns = _.groupBy(localeFilesAndPatterns, "pattern"); const patterns = Object.keys(grouppedFilesAndPatterns);