mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 22:57:46 +00:00
write a simple directory name linter
You can explore the behavior of this script by setting up some temporary directories: ```bash mkdir -p /tmp/linting/2.0.0 mkdir -p /tmp/linting/yeah_whatever_linter ``` Then, run the linter ```bash cd /tmp/linting nu ./lint_directories.nu ```
This commit is contained in:
parent
a9ec44083e
commit
28fb24315a
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:'
|
||||||
|
ls-incorrect-dirs
|
||||||
|
exit 1
|
||||||
|
} {
|
||||||
|
exit 0
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue