Skip to content

Commit 540565f

Browse files
authored
fix: glob pattern case sensivitve (#336)
1 parent 270c51e commit 540565f

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

.changeset/forty-zoos-sell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'dotenv-diff': patch
3+
---
4+
5+
Case sensitive for glob pattern fix

packages/cli/src/services/fileWalker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,6 @@ export function matchesGlobPattern(filePath: string, pattern: string): boolean {
286286
.replace(/___DOUBLESTAR___/g, '.*')
287287
.replace(/\?/g, '[^/]');
288288

289-
const re = new RegExp(`^${regexPattern}$`, 'i');
289+
const re = new RegExp(`^${regexPattern}$`);
290290
return re.test(normalized);
291291
}

packages/cli/test/unit/services/filewalker.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { describe, it, expect, beforeEach, afterEach } from 'vitest';
22
import fs from 'fs';
33
import path from 'path';
44
import os from 'os';
5+
import { execSync } from 'child_process';
56
import {
67
findFiles,
78
expandBraceSets,
@@ -184,9 +185,9 @@ describe('filewalker', () => {
184185
expect(result).toBe(false);
185186
});
186187

187-
it('handles case insensitive matching', () => {
188+
it('is case sensitive for glob matching', () => {
188189
const result = matchesGlobPattern('src/App.JS', '**/*.js');
189-
expect(result).toBe(true);
190+
expect(result).toBe(false);
190191
});
191192

192193
it('handles patterns without separators', () => {
@@ -278,13 +279,12 @@ describe('filewalker', () => {
278279

279280
try {
280281
// Try to create a FIFO (named pipe) - only works on Unix-like systems
281-
const { execSync } = require('child_process');
282282
execSync(`mkfifo "${pipePath}"`);
283283

284284
const result = getPatternBaseDir(tmpDir, 'testpipe');
285285
// FIFO is neither file nor directory
286286
expect(result).toBeNull();
287-
} catch (err) {
287+
} catch {
288288
// Skip on Windows or if mkfifo not available
289289
console.log('FIFO test skipped - not supported on this system');
290290
expect(true).toBe(true); // Dummy assertion so test doesn't fail
@@ -409,7 +409,6 @@ describe('filewalker', () => {
409409
});
410410

411411
it('walks extra roots for patterns outside cwd', async () => {
412-
const parentDir = path.dirname(tmpDir);
413412
const srcDir = path.join(tmpDir, 'src');
414413
fs.mkdirSync(srcDir);
415414
fs.writeFileSync(path.join(srcDir, 'app.js'), '');

0 commit comments

Comments
 (0)