diff options
author | Julien Dessaux | 2021-10-04 18:38:10 +0200 |
---|---|---|
committer | Julien Dessaux | 2021-10-04 18:38:10 +0200 |
commit | 161f0a3bf652f2f513a61489276958835eca4a41 (patch) | |
tree | b313d494ae73ec708b27b30d88927a3479c66019 /nimfunge98.nimble | |
parent | Implemented the stackstack (diff) | |
download | nimfunge98-161f0a3bf652f2f513a61489276958835eca4a41.tar.gz nimfunge98-161f0a3bf652f2f513a61489276958835eca4a41.tar.bz2 nimfunge98-161f0a3bf652f2f513a61489276958835eca4a41.zip |
Added a nimble task to run nimpretty on all gitted files
Diffstat (limited to '')
-rw-r--r-- | nimfunge98.nimble | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/nimfunge98.nimble b/nimfunge98.nimble index 71d4e92..c3a0443 100644 --- a/nimfunge98.nimble +++ b/nimfunge98.nimble @@ -19,7 +19,25 @@ task test, "Runs the test suite": task coverage, "Run all tests and calculate coverage": exec "coco --target 'tests/**/*.nim' --cov '!tests,!nimcache'" +import os, strformat + +task fmt, "Run nimpretty on all git-managed .nim files in the current repo": + ## Usage: nim fmt + for file in walkDirRec("./", {pcFile, pcDir}): + if file.splitFile().ext == ".nim": + let + # https://github.com/nim-lang/Nim/issues/6262#issuecomment-454983572 + # https://stackoverflow.com/a/2406813/1219634 + fileIsGitManaged = gorgeEx("cd $1 && git ls-files --error-unmatch $2" % [getCurrentDir(), file]).exitCode == 0 + # ^^^^^-- That "cd" is required. + if fileIsGitManaged: + let + cmd = "nimpretty --maxLineLen=180 $1" % [file] + echo "Running $1 .." % [cmd] + exec(cmd) + task clean, "Clean": exec "rm -rf coverage lcov.info nimcache" exec "rm -rf outputGotten.txt testresults tests/megatest.nim" + exec "rm -rf src/htmldocs" exec "find tests/ -type f -executable -delete" |