mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-18 17:08:32 +00:00
This commit is contained in:
@@ -5,9 +5,10 @@ when not declared(os) and not declared(ospaths):
|
||||
|
||||
when defined(nodejs):
|
||||
proc getEnv*(key: string, default = ""): string {.tags: [ReadEnvEffect].} =
|
||||
var ret: cstring
|
||||
var ret = default.cstring
|
||||
let key2 = key.cstring
|
||||
{.emit: "`ret` = process.env[`key2`];".}
|
||||
{.emit: "const value = process.env[`key2`];".}
|
||||
{.emit: "if (value !== undefined) { `ret` = value };".}
|
||||
result = $ret
|
||||
|
||||
proc existsEnv*(key: string): bool {.tags: [ReadEnvEffect].} =
|
||||
|
||||
@@ -520,7 +520,7 @@ block ospaths:
|
||||
# but not `./foo/bar` and `foo/bar`
|
||||
doAssert joinPath(".", "/lib") == unixToNativePath"./lib"
|
||||
doAssert joinPath(".","abc") == unixToNativePath"./abc"
|
||||
|
||||
|
||||
# cases related to issue #13455
|
||||
doAssert joinPath("foo", "", "") == "foo"
|
||||
doAssert joinPath("foo", "") == "foo"
|
||||
@@ -566,6 +566,10 @@ block osenv:
|
||||
doAssert existsEnv(dummyEnvVar) == false
|
||||
delEnv(dummyEnvVar) # deleting an already deleted env var
|
||||
doAssert existsEnv(dummyEnvVar) == false
|
||||
block:
|
||||
doAssert getEnv("DUMMY_ENV_VAR_NONEXISTENT", "") == ""
|
||||
doAssert getEnv("DUMMY_ENV_VAR_NONEXISTENT", " ") == " "
|
||||
doAssert getEnv("DUMMY_ENV_VAR_NONEXISTENT", "Arrakis") == "Arrakis"
|
||||
|
||||
block isRelativeTo:
|
||||
doAssert isRelativeTo("/foo", "/")
|
||||
|
||||
Reference in New Issue
Block a user