feat(checks): Add linters
This commit is contained in:
parent
fc991a0b07
commit
5c6b697e55
3 changed files with 92 additions and 1 deletions
checks
39
checks/lints.nu
Normal file
39
checks/lints.nu
Normal file
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/env nu
|
||||
|
||||
let shell_files = ls **/*.sh | get name
|
||||
let nix_files = ls **/*.nix | where name !~ "hardware-configuration.nix|_sources" | get name
|
||||
|
||||
let linters = [
|
||||
([shellcheck] ++ $shell_files)
|
||||
([nixfmt --check --strict] ++ $nix_files)
|
||||
([deadnix --fail] ++ $nix_files)
|
||||
([statix check] ++ $nix_files)
|
||||
]
|
||||
|
||||
mkdir $env.out
|
||||
|
||||
def run-linter [linterArgs: list<string>] {
|
||||
print $'Running ($linterArgs.0)...'
|
||||
|
||||
let exit_code = try {
|
||||
^$linterArgs.0 ...($linterArgs | skip 1)
|
||||
$env.LAST_EXIT_CODE
|
||||
} catch {|e| $e.exit_code}
|
||||
|
||||
[$linterArgs.0, $exit_code]
|
||||
}
|
||||
|
||||
let results = $linters | each {|linter| run-linter $linter}
|
||||
|
||||
print 'Linter results:'
|
||||
|
||||
let success = $results | each {|result|
|
||||
match $result.1 {
|
||||
0 => {print $'(ansi green)($result.0)(ansi reset)'}
|
||||
_ => {print $'(ansi red)($result.0)(ansi reset)'}
|
||||
}
|
||||
|
||||
$result.1
|
||||
} | math sum
|
||||
|
||||
exit $success
|
Loading…
Add table
Add a link
Reference in a new issue