forked from tauri-apps/tauri
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcargo-check.ps1
executable file
·54 lines (48 loc) · 1.13 KB
/
cargo-check.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env pwsh
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: MIT
# note: you can pass in the cargo sub-commands used to check manually.
# allowed commands: check, clippy, fmt, test
# default: clippy, fmt, test
# 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
}
}
function run {
$command, $_args = $args
Write-Output "[$command]"
cargo $command --workspace --all-targets --all-features $_args
check_error
}
foreach ($command in $args) {
Switch ($command) {
"check" {
run check
break
}
"test" {
run test
break
}
"clippy" {
run clippy "--" -D warnings
break
}
"fmt" {
Write-Output "[$command] checking formatting"
cargo +nightly fmt "--" --check
check_error
}
default {
Write-Output "[cargo-check.ps1] Unknown cargo sub-command: $command"
Exit 1
}
}
}