2020-07-24 17:19:02 +03:00
|
|
|
#!/usr/bin/env pwsh
|
2022-08-28 21:13:21 +03:00
|
|
|
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
2021-04-11 01:09:09 +03:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
2020-07-24 17:19:02 +03:00
|
|
|
# note: you can pass in the cargo sub-commands used to check manually.
|
|
|
|
# allowed commands: check, clippy, fmt, test
|
|
|
|
# default: clippy, fmt, test
|
2020-07-21 20:35:22 +03:00
|
|
|
|
2020-07-24 17:19:02 +03:00
|
|
|
# set the script arguments if none are found
|
|
|
|
if(-Not $args) {
|
|
|
|
$args=@("clippy","fmt","test")
|
|
|
|
}
|
|
|
|
|
|
|
|
# exit the script early if the last command returned an error
|
|
|
|
function check_error {
|
|
|
|
if($LASTEXITCODE -ne 0 ) {
|
|
|
|
Exit $LASTEXITCODE
|
|
|
|
}
|
|
|
|
}
|
2020-07-21 20:35:22 +03:00
|
|
|
|
2021-02-10 08:24:38 +03:00
|
|
|
function run {
|
2020-07-24 17:19:02 +03:00
|
|
|
$command, $_args = $args
|
|
|
|
|
2021-02-10 08:24:38 +03:00
|
|
|
Write-Output "[$command]"
|
|
|
|
cargo $command --workspace --all-targets --all-features $_args
|
2020-07-24 17:19:02 +03:00
|
|
|
check_error
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($command in $args) {
|
|
|
|
Switch ($command) {
|
|
|
|
"check" {
|
2021-02-10 08:24:38 +03:00
|
|
|
run check
|
2020-07-24 17:19:02 +03:00
|
|
|
break
|
|
|
|
}
|
|
|
|
"test" {
|
2021-02-10 08:24:38 +03:00
|
|
|
run test
|
2020-07-24 17:19:02 +03:00
|
|
|
break
|
|
|
|
}
|
|
|
|
"clippy" {
|
2021-02-10 08:24:38 +03:00
|
|
|
run clippy "--" -D warnings
|
2020-07-24 17:19:02 +03:00
|
|
|
break
|
|
|
|
}
|
|
|
|
"fmt" {
|
|
|
|
Write-Output "[$command] checking formatting"
|
2021-04-04 03:41:04 +03:00
|
|
|
cargo +nightly fmt "--" --check
|
2020-07-24 17:19:02 +03:00
|
|
|
check_error
|
|
|
|
}
|
|
|
|
default {
|
|
|
|
Write-Output "[cargo-check.ps1] Unknown cargo sub-command: $command"
|
|
|
|
Exit 1
|
|
|
|
}
|
|
|
|
}
|
2020-07-21 20:35:22 +03:00
|
|
|
}
|