1
Fork 0
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:
Darren Schroeder 2021-04-06 11:28:01 -05:00 committed by GitHub
commit 2926a45137
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

15
lint_directories.nu Executable file
View 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
}