mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 17:34:43 +00:00
* * relativePath(foo) now works * relativePath(rel, abs) and relativePath(abs, rel) now work (fixes #13222) * relativePath, absolutePath, getCurrentDir now available in more targets (eg: vm, nodejs etc) * fix bug: isAbsolutePath now works with -d:js; add tests * workaround https://github.com/nim-lang/Nim/issues/13469 * remove `relativePath(path)` overload for now * add back changelog after rebase
22 lines
698 B
Nim
22 lines
698 B
Nim
static: doAssert defined(nodejs)
|
|
|
|
import os
|
|
|
|
block:
|
|
doAssert "./foo//./bar/".normalizedPath == "foo/bar"
|
|
doAssert relativePath(".//foo/bar", "foo") == "bar"
|
|
doAssert "/".isAbsolute
|
|
doAssert not "".isAbsolute
|
|
doAssert not ".".isAbsolute
|
|
doAssert not "foo".isAbsolute
|
|
doAssert relativePath("", "bar") == ""
|
|
doAssert normalizedPath(".///foo//./") == "foo"
|
|
let cwd = getCurrentDir()
|
|
|
|
let isWindows = '\\' in cwd
|
|
# defined(windows) doesn't work with -d:nodejs but should
|
|
# these actually break because of that (see https://github.com/nim-lang/Nim/issues/13469)
|
|
if not isWindows:
|
|
doAssert cwd.isAbsolute
|
|
doAssert relativePath(getCurrentDir() / "foo", "bar") == "../foo"
|