Skip to content

Commit 17d9a6d

Browse files
committed
Fix: workaround cargo sort issues
1 parent 1288cb1 commit 17d9a6d

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

builder/src/main.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,36 @@ fn run_update() -> Result<(), Box<dyn std::error::Error>> {
321321
}
322322

323323
fn run_check() -> Result<(), Box<dyn std::error::Error>> {
324+
// On Windows, `cargo sort --check` fails since it default to LF, not CRLF,
325+
// line endings. Work around this by changing this setting only on Windows.
326+
// See the
327+
// [cargo sort config docs](https://github.com/DevinR528/cargo-sort?tab=readme-ov-file#config)
328+
// and the
329+
// [related issue](https://github.com/DevinR528/cargo-sort/issues/85).
330+
//
331+
// However, this still fails: `cargo sort` uses
332+
// [inconsistent line endings](https://github.com/DevinR528/cargo-sort/issues/86).
333+
/***
334+
#[cfg(windows)]
335+
{
336+
fs::write("tomlfmt.toml", "crlf = true")
337+
.map_err(|err| -> String { format!("Unable to write tomlfmt.toml: {err}") })?;
338+
}
339+
*/
324340
// The `-D warnings` flag causes clippy to return a non-zero exit status if
325341
// it issues warnings.
326342
run_cmd!(
327343
cargo clippy --all-targets -- -D warnings;
328344
cargo fmt --check;
345+
cargo clippy --all-targets --manifest-path=../builder/Cargo.toml -- -D warnings;
346+
cargo fmt --check --manifest-path=../builder/Cargo.toml;
347+
)?;
348+
// `cargo sort` produces false positives under Windows. Ignore for now. See
349+
// the above comments. It also doesn't support the
350+
#[cfg(not(windows))]
351+
run_cmd!(
329352
cargo sort --check;
330353
cd ../builder;
331-
cargo clippy --all-targets -- -D warnings;
332-
cargo fmt --check;
333354
cargo sort --check;
334355
)?;
335356
run_build()?;

0 commit comments

Comments
 (0)