1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-02 07:07: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:
Eli Flanagan 2021-04-06 11:53:57 -04:00
parent a9ec44083e
commit 28fb24315a

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:'
ls-incorrect-dirs
exit 1
} {
exit 0
}