HotFix: Support spaces in binary paths for doCmdEx.
This commit is contained in:
parent
f0dd4a1efc
commit
436b7c6e93
1 changed files with 10 additions and 4 deletions
|
|
@ -2,11 +2,17 @@
|
||||||
# BSD License. Look at license.txt for more info.
|
# BSD License. Look at license.txt for more info.
|
||||||
#
|
#
|
||||||
# Various miscellaneous utility functions reside here.
|
# Various miscellaneous utility functions reside here.
|
||||||
import osproc, pegs, strutils, os, uri, sets, json
|
import osproc, pegs, strutils, os, uri, sets, json, parseutils
|
||||||
import version, packageinfo, nimbletypes
|
import version, packageinfo, nimbletypes
|
||||||
|
|
||||||
|
proc extractBin(cmd: string): string =
|
||||||
|
if cmd[0] == '"':
|
||||||
|
return cmd.captureBetween('"')
|
||||||
|
else:
|
||||||
|
return cmd.split(' ')[0]
|
||||||
|
|
||||||
proc doCmd*(cmd: string) =
|
proc doCmd*(cmd: string) =
|
||||||
let bin = cmd.split(' ')[0]
|
let bin = extractBin(cmd)
|
||||||
if findExe(bin) == "":
|
if findExe(bin) == "":
|
||||||
raise newException(NimbleError, "'" & bin & "' not in PATH.")
|
raise newException(NimbleError, "'" & bin & "' not in PATH.")
|
||||||
|
|
||||||
|
|
@ -21,7 +27,7 @@ proc doCmd*(cmd: string) =
|
||||||
"Execution failed with exit code " & $exitCode)
|
"Execution failed with exit code " & $exitCode)
|
||||||
|
|
||||||
proc doCmdEx*(cmd: string): tuple[output: TaintedString, exitCode: int] =
|
proc doCmdEx*(cmd: string): tuple[output: TaintedString, exitCode: int] =
|
||||||
let bin = cmd.split(' ')[0]
|
let bin = extractBin(cmd)
|
||||||
if findExe(bin) == "":
|
if findExe(bin) == "":
|
||||||
raise newException(NimbleError, "'" & bin & "' not in PATH.")
|
raise newException(NimbleError, "'" & bin & "' not in PATH.")
|
||||||
return execCmdEx(cmd)
|
return execCmdEx(cmd)
|
||||||
|
|
@ -41,7 +47,7 @@ proc getNimBin*: string =
|
||||||
|
|
||||||
proc getNimrodVersion*: Version =
|
proc getNimrodVersion*: Version =
|
||||||
let nimBin = getNimBin()
|
let nimBin = getNimBin()
|
||||||
let vOutput = doCmdEx(nimBin & " -v").output
|
let vOutput = doCmdEx('"' & nimBin & "\" -v").output
|
||||||
var matches: array[0..MaxSubpatterns, string]
|
var matches: array[0..MaxSubpatterns, string]
|
||||||
if vOutput.find(peg"'Version'\s{(\d+\.)+\d}", matches) == -1:
|
if vOutput.find(peg"'Version'\s{(\d+\.)+\d}", matches) == -1:
|
||||||
quit("Couldn't find Nim version.", QuitFailure)
|
quit("Couldn't find Nim version.", QuitFailure)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue