Created
March 11, 2023 12:45
-
-
Save Dzejkop/94ce3cea010eb2e25b952fa8fd7bc70f to your computer and use it in GitHub Desktop.
Nu Scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def findMod [path: path] { | |
ls -a $path | where type == 'file' | where name =~ 'mod.rs' | select name | each {|e| handleModFile $e.name } | |
if ($path | path exists) { | |
ls -a $path | where type == 'dir' | select name | each {|e| findMod ($path | path join $e.name) } | |
} | |
} | |
def handleModFile [path: path] { | |
let d = ($path | path dirname) | |
let f = ([$d ".rs"] | str join) | |
mv $path $f | |
if isEmpyDir $d { | |
rm -rf $d | |
} | |
} | |
def isEmpyDir [path: path] { | |
(ls -a $path | length) == 0 | |
} | |
def main [path: path] { | |
findMod $path | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment