aboutsummaryrefslogtreecommitdiff
path: root/nimfunge98.nimble
blob: 9428df9a80db0220844b9ac9afcf5526af83f2b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Package

version       = "1.0.1"
author        = "Julien Dessaux"
description   = "A Funge-98 interpreter written in nim"
license       = "EUPL-1.2"
srcDir        = "src"
bin           = @["nimfunge98"]

# Dependencies

requires "nim >= 1.4.8"

# Tasks

task tests, "Runs the test suite":
  exec "testament pattern \"tests/*.nim\""

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=220 $1" % [file]
        echo "Running $1 .." % [cmd]
        exec(cmd)

task clean, "Clean":
  exec "rm -rf nimcache testresults tests/megatest.nim"
  exec "find tests/ -type f -executable -delete"