Add nimble dir to path via finish
This commit is contained in:
parent
7cf87dfac6
commit
9bde9a1404
1 changed files with 20 additions and 7 deletions
|
|
@ -187,12 +187,14 @@ when defined(windows):
|
||||||
|
|
||||||
proc main() =
|
proc main() =
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
let desiredPath = expandFilename(getCurrentDir() / "bin")
|
let nimDesiredPath = expandFilename(getCurrentDir() / "bin")
|
||||||
|
let nimbleDesiredPath = expandFilename(getEnv("USERPROFILE") / ".nimble" / "bin")
|
||||||
let p = tryGetUnicodeValue(r"Environment", "Path",
|
let p = tryGetUnicodeValue(r"Environment", "Path",
|
||||||
HKEY_CURRENT_USER) & ";" & tryGetUnicodeValue(
|
HKEY_CURRENT_USER) & ";" & tryGetUnicodeValue(
|
||||||
r"System\CurrentControlSet\Control\Session Manager\Environment", "Path",
|
r"System\CurrentControlSet\Control\Session Manager\Environment", "Path",
|
||||||
HKEY_LOCAL_MACHINE)
|
HKEY_LOCAL_MACHINE)
|
||||||
var alreadyInPath = false
|
var nimAlreadyInPath = false
|
||||||
|
var nimbleAlreadyInPath = false
|
||||||
var mingWchoices: seq[string] = @[]
|
var mingWchoices: seq[string] = @[]
|
||||||
var incompat: seq[string] = @[]
|
var incompat: seq[string] = @[]
|
||||||
for x in p.split(';'):
|
for x in p.split(';'):
|
||||||
|
|
@ -200,18 +202,29 @@ proc main() =
|
||||||
let y = try: expandFilename(if x[0] == '"' and x[^1] == '"':
|
let y = try: expandFilename(if x[0] == '"' and x[^1] == '"':
|
||||||
substr(x, 1, x.len-2) else: x)
|
substr(x, 1, x.len-2) else: x)
|
||||||
except: ""
|
except: ""
|
||||||
if y.cmpIgnoreCase(desiredPath) == 0: alreadyInPath = true
|
if y.cmpIgnoreCase(nimDesiredPath) == 0:
|
||||||
if y.toLowerAscii.contains("mingw"):
|
nimAlreadyInPath = true
|
||||||
|
elif y.cmpIgnoreCase(nimbleDesiredPath) == 0:
|
||||||
|
nimbleAlreadyInPath = true
|
||||||
|
elif y.toLowerAscii.contains("mingw"):
|
||||||
if dirExists(y):
|
if dirExists(y):
|
||||||
if checkGccArch(y): mingWchoices.add y
|
if checkGccArch(y): mingWchoices.add y
|
||||||
else: incompat.add y
|
else: incompat.add y
|
||||||
|
|
||||||
if alreadyInPath:
|
if nimAlreadyInPath:
|
||||||
echo "bin/nim.exe is already in your PATH [Skipping]"
|
echo "bin\\nim.exe is already in your PATH [Skipping]"
|
||||||
else:
|
else:
|
||||||
if askBool("nim.exe is not in your PATH environment variable.\n" &
|
if askBool("nim.exe is not in your PATH environment variable.\n" &
|
||||||
"Should it be added permanently? (y/n) "):
|
"Should it be added permanently? (y/n) "):
|
||||||
addToPathEnv(desiredPath)
|
addToPathEnv(nimDesiredPath)
|
||||||
|
|
||||||
|
if nimbleAlreadyInPath:
|
||||||
|
echo nimbleDesiredPath & " is already in your PATH [Skipping]"
|
||||||
|
else:
|
||||||
|
if askBool(nimbleDesiredPath & " is not in your PATH environment variable.\n" &
|
||||||
|
"Should it be added permanently? (y/n) "):
|
||||||
|
addToPathEnv(nimbleDesiredPath)
|
||||||
|
|
||||||
if mingWchoices.len == 0:
|
if mingWchoices.len == 0:
|
||||||
# No mingw in path, so try a few locations:
|
# No mingw in path, so try a few locations:
|
||||||
let alternative = tryDirs(incompat, defaultMingwLocations())
|
let alternative = tryDirs(incompat, defaultMingwLocations())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue