mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
Merge pull request #39 from efx/lint-directories
write a simple directory name linter
This commit is contained in:
commit
2926a45137
1 changed files with 15 additions and 0 deletions
15
lint_directories.nu
Executable file
15
lint_directories.nu
Executable file
|
@ -0,0 +1,15 @@
|
|||
# List any directory that does not follow a SemVer naming pattern
|
||||
# For example
|
||||
# - 1.0.1 is a valid directory name.
|
||||
# - yeah_whatever_linter is not a valid directory name.
|
||||
def ls-incorrect-dirs [] {
|
||||
ls | where type == 'Dir' && name != 'scripts'| match -v name '(\d+\.){2,}\d$'
|
||||
}
|
||||
let incorrect_count = $(ls-incorrect-dirs | length);
|
||||
if $incorrect_count > 0 {
|
||||
echo `The following directories are named incorrectly: {{$(char newline)}}`
|
||||
ls-incorrect-dirs
|
||||
exit 1
|
||||
} {
|
||||
exit 0
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue