Add mkdir to git, use in downloadUrl
This commit is contained in:
parent
d6932247a9
commit
74f4485ecd
1 changed files with 11 additions and 4 deletions
|
|
@ -22,6 +22,11 @@ proc execAction*(cmd: string, nostderr=false): string =
|
||||||
let msg = "Command failed: " & $ret & "\nccmd: " & ccmd & "\nresult:\n" & result
|
let msg = "Command failed: " & $ret & "\nccmd: " & ccmd & "\nresult:\n" & result
|
||||||
doAssert false, msg
|
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) =
|
proc extractZip*(zipfile, outdir: string) =
|
||||||
var cmd = "unzip -o $#"
|
var cmd = "unzip -o $#"
|
||||||
if defined(Windows):
|
if defined(Windows):
|
||||||
|
|
@ -39,14 +44,15 @@ proc downloadUrl*(url, outdir: string) =
|
||||||
|
|
||||||
if not (ext == ".zip" and fileExists(outdir/file)):
|
if not (ext == ".zip" and fileExists(outdir/file)):
|
||||||
echo "Downloading " & file
|
echo "Downloading " & file
|
||||||
|
mkDir(outdir)
|
||||||
var cmd = if defined(Windows):
|
var cmd = if defined(Windows):
|
||||||
"powershell wget $# -OutFile $#"
|
"powershell wget $# -OutFile $#"
|
||||||
else:
|
else:
|
||||||
"curl $# -o $#"
|
"curl $# -o $#"
|
||||||
discard execAction(cmd % [url, outdir/file])
|
discard execAction(cmd % [url, outdir/file])
|
||||||
|
|
||||||
if ext == ".zip":
|
if ext == ".zip":
|
||||||
extractZip(file, outdir)
|
extractZip(file, outdir)
|
||||||
|
|
||||||
proc gitReset*(outdir: string) =
|
proc gitReset*(outdir: string) =
|
||||||
echo "Resetting " & outdir
|
echo "Resetting " & outdir
|
||||||
|
|
@ -77,10 +83,11 @@ proc gitPull*(url: string, outdir = "", plist = "", checkout = "") =
|
||||||
if dirExists(outdir/".git"):
|
if dirExists(outdir/".git"):
|
||||||
gitReset(outdir)
|
gitReset(outdir)
|
||||||
return
|
return
|
||||||
|
|
||||||
let
|
let
|
||||||
outdir2 = outdir.quoteShell
|
outdir2 = outdir.quoteShell
|
||||||
flag = when not defined(Windows): "-p" else: ""
|
|
||||||
echo execAction(&"mkdir {flag} {outdir2}")
|
mkDir(outdir2)
|
||||||
|
|
||||||
echo "Setting up Git repo: " & url
|
echo "Setting up Git repo: " & url
|
||||||
discard execAction(&"cd {outdir2} && git init .")
|
discard execAction(&"cd {outdir2} && git init .")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue