Skip to content

Commit fa10544

Browse files
committed
fix(oxfmt): Normalize path delimiter on Windows
1 parent 368829b commit fa10544

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
- run: git diff --exit-code # Must commit everything
6464

6565
test-windows:
66-
if: ${{ github.ref_name == 'main' }}
66+
# if: ${{ github.ref_name == 'main' }}
6767
name: Test Windows
6868
runs-on: windows-latest
6969
steps:

apps/oxfmt/tests/snapshots/tests__fixtures__config_file_--check --config .__fmt.json --check --config .__fmt.jsonc --check --config NOT_EXISTS.json@oxfmt.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ arguments: --check --config NOT_EXISTS.json
3232
working directory: tests/fixtures/config_file
3333
----------
3434
Failed to load configuration file.
35-
Failed to read config <cwd>/tests/fixtures/config_file/NOT_EXISTS.json: No such file or directory (os error 2)
35+
Failed to read config <cwd>/tests/fixtures/config_file/NOT_EXISTS.json: File not found
3636
----------
3737
CLI result: InvalidOptionConfig
3838
----------

apps/oxfmt/tests/tester.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ impl Tester {
7979
let regex = Regex::new(r"\d+(?:\.\d+)?s|\d+ms").unwrap();
8080
let output_string = regex.replace_all(output_string, "<variable>ms").into_owned();
8181

82+
// Normalize all backslashes to forward slashes first (for Windows paths)
83+
let output_string = output_string.cow_replace('\\', "/").to_string();
84+
8285
// do not output the current working directory, each machine has a different one
8386
let current_cwd_string = current_cwd.to_str().unwrap();
8487
let current_cwd_string = current_cwd_string.cow_replace('\\', "/").to_string(); // for windows

crates/oxc_formatter/src/service/oxfmtrc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ impl Oxfmtrc {
8787
pub fn from_file(path: &Path) -> Result<Self, String> {
8888
// TODO: Use `simdutf8` like `oxc_linter`?
8989
let mut string = std::fs::read_to_string(path)
90-
.map_err(|err| format!("Failed to read config {}: {err}", path.display()))?;
90+
// Do not include OS error, it differs between platforms
91+
.map_err(|_| format!("Failed to read config {}: File not found", path.display()))?;
9192

9293
// JSONC support - strip comments
9394
json_strip_comments::strip(&mut string)

0 commit comments

Comments
 (0)