Repository navigation
Fix case-sensitive file path comparison in watch mode on Windows #19774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mvanhorn
wants to merge
5
commits into
tailwindlabs:main
Choose a base branch
from
mvanhorn:osc/16784-fix-watch-case-sensitive
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8021b80
fix(cli): use case-insensitive path comparison on Windows in watch mode
mvanhorn fe0f497
Merge upstream/main and apply the Windows path comparison to the new …
mvanhorn a1a6f10
Cover the Windows rebuild decision in watch mode
mvanhorn 6a030fc
Add a Windows watch mode test for differently cased input paths
mvanhorn 73a2bd2
Merge branch 'main' of https://github.com/tailwindlabs/tailwindcss
mvanhorn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ### Fixed | ||
|
|
||
| - Ensure `@tailwindcss/cli` compares file paths case-insensitively on Windows in watch mode ([#16784](https://github.com/tailwindlabs/tailwindcss/issues/16784)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/@tailwindcss-cli/src/commands/build/utils.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { getRebuildStrategy } from './utils' | ||
|
|
||
| describe('getRebuildStrategy', () => { | ||
| it('rebuilds fully when a differently cased input file changes on Windows', () => { | ||
| let input = 'C:\\Project\\src\\input.css' | ||
| let changed = 'c:\\project\\src\\Input.css' | ||
|
|
||
| expect(getRebuildStrategy([changed], [input], 'win32')).toEqual({ kind: 'full' }) | ||
| }) | ||
|
|
||
| it('stays incremental for a differently cased path on case-sensitive platforms', () => { | ||
| expect(getRebuildStrategy(['/src/Input.css'], ['/src/input.css'], 'linux')).toEqual({ | ||
| kind: 'incremental', | ||
| changedFiles: [{ file: '/src/Input.css', extension: 'css' }], | ||
| }) | ||
| }) | ||
|
|
||
| it('stays incremental on Windows for a file that is not a rebuild path', () => { | ||
| expect(getRebuildStrategy(['C:\\src\\index.html'], ['C:\\src\\input.css'], 'win32')).toEqual({ | ||
| kind: 'incremental', | ||
| changedFiles: [{ file: 'C:\\src\\index.html', extension: 'html' }], | ||
| }) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { pathsEqual } from './paths-equal' | ||
|
|
||
| describe('pathsEqual', () => { | ||
| it('returns true for identical paths', () => { | ||
| expect(pathsEqual('/foo/bar/baz.css', '/foo/bar/baz.css')).toBe(true) | ||
| }) | ||
|
|
||
| it('returns false for completely different paths', () => { | ||
| expect(pathsEqual('/foo/bar.css', '/foo/baz.css')).toBe(false) | ||
| }) | ||
|
|
||
| it('ignores case on Windows', () => { | ||
| expect(pathsEqual('C:\\src\\Input.css', 'C:\\src\\input.css', 'win32')).toBe(true) | ||
| }) | ||
|
|
||
| it('still compares different paths on Windows', () => { | ||
| expect(pathsEqual('C:\\src\\input.css', 'C:\\src\\other.css', 'win32')).toBe(false) | ||
| }) | ||
|
|
||
| it('respects case on other platforms', () => { | ||
| expect(pathsEqual('/src/Input.css', '/src/input.css', 'linux')).toBe(false) | ||
| expect(pathsEqual('/src/Input.css', '/src/input.css', 'darwin')).toBe(false) | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /** | ||
| * Compare two file paths for equality. On Windows, the comparison is | ||
| * case-insensitive because the filesystem is case-insensitive. | ||
| */ | ||
| export function pathsEqual( | ||
| a: string, | ||
| b: string, | ||
| platform: NodeJS.Platform = process.platform, | ||
| ): boolean { | ||
| if (platform === 'win32') { | ||
| return a.toLowerCase() === b.toLowerCase() | ||
| } | ||
| return a === b | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.