diff options
| author | Ganesh Viswanathan <dev@genotrance.com> | 2019-02-02 00:38:18 -0600 |
|---|---|---|
| committer | Ganesh Viswanathan <dev@genotrance.com> | 2019-02-02 00:38:18 -0600 |
| commit | 74f4485ecdf09a6446bcdeefcae17f5020324172 (patch) | |
| tree | 78d338c157ffc77a034808a63b88b1314183f20b | |
| parent | d6932247a9af7fe3eb83363c42c99c7e6f6d13b5 (diff) | |
| download | nimterop-74f4485ecdf09a6446bcdeefcae17f5020324172.tar.gz nimterop-74f4485ecdf09a6446bcdeefcae17f5020324172.zip | |
Add mkdir to git, use in downloadUrl
| -rw-r--r-- | nimterop/git.nim | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/nimterop/git.nim b/nimterop/git.nim index 2315204..ee170b2 100644 --- a/nimterop/git.nim +++ b/nimterop/git.nim @@ -22,6 +22,11 @@ proc execAction*(cmd: string, nostderr=false): string = let msg = "Command failed: " & $ret & "\nccmd: " & ccmd & "\nresult:\n" & result doAssert false, msg +proc mkDir*(dir: string) = + let + flag = when not defined(Windows): "-p" else: "" + discard execAction(&"mkdir {flag} {dir.quoteShell}") + proc extractZip*(zipfile, outdir: string) = var cmd = "unzip -o $#" if defined(Windows): @@ -39,14 +44,15 @@ proc downloadUrl*(url, outdir: string) = if not (ext == ".zip" and fileExists(outdir/file)): echo "Downloading " & file + mkDir(outdir) var cmd = if defined(Windows): "powershell wget $# -OutFile $#" else: "curl $# -o $#" discard execAction(cmd % [url, outdir/file]) - if ext == ".zip": - extractZip(file, outdir) + if ext == ".zip": + extractZip(file, outdir) proc gitReset*(outdir: string) = echo "Resetting " & outdir @@ -77,10 +83,11 @@ proc gitPull*(url: string, outdir = "", plist = "", checkout = "") = if dirExists(outdir/".git"): gitReset(outdir) return + let outdir2 = outdir.quoteShell - flag = when not defined(Windows): "-p" else: "" - echo execAction(&"mkdir {flag} {outdir2}") + + mkDir(outdir2) echo "Setting up Git repo: " & url discard execAction(&"cd {outdir2} && git init .") |
