diff --git a/README.md b/README.md index e055c233a..294e72aa0 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ The following core Node.js modules (v8.7.0+) have been implemented: | [https](https://nodejs.org/api/https.html) | | | [net](https://nodejs.org/api/net.html) | | | [os](https://nodejs.org/api/os.html) | :heavy_check_mark: | -| [path](https://nodejs.org/api/path.html) | | +| [path](https://nodejs.org/api/path.html) | :heavy_check_mark: | | [process](https://nodejs.org/api/process.html) | | | [querystring](https://nodejs.org/api/querystring.html) | :heavy_check_mark: | | [readline](https://nodejs.org/api/readline.html) | | diff --git a/app/current/src/main/scala/io/scalajs/nodejs/path/Path.scala b/app/current/src/main/scala/io/scalajs/nodejs/path/Path.scala index 77bd15256..1805ec27f 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/path/Path.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/path/Path.scala @@ -1,5 +1,7 @@ package io.scalajs.nodejs.path +import com.thoughtworks.enableIf + import scala.scalajs.js import scala.scalajs.js.annotation.JSImport @@ -18,22 +20,22 @@ trait Path extends js.Object { /** * The platform-specific path delimiter, ';' or ':'. */ - def delimiter: String = js.native + val delimiter: String = js.native /** * Provide access to aforementioned path methods but always interact in a posix compatible way. */ - def posix: Path = js.native + val posix: Path = js.native /** * The platform-specific file separator, '\\' or '/'. */ - def sep: String = js.native + val sep: String = js.native /** * Provide access to aforementioned path methods but always interact in a win32 compatible way. */ - def win32: Path = js.native + val win32: Path = js.native ///////////////////////////////////////////////////////////////////////////////// // Methods @@ -133,6 +135,8 @@ trait Path extends js.Object { */ def resolve(args: String*): String = js.native + @enableIf(io.scalajs.nodejs.CompilerSwitches.gteNodeJs10) + def toNamespacedPath(path: String): String = js.native } /** diff --git a/app/nodejs-v10/src/test/scala/nodejs/path/PathTest.scala b/app/nodejs-v10/src/test/scala/nodejs/path/PathTest.scala new file mode 100644 index 000000000..57697cca9 --- /dev/null +++ b/app/nodejs-v10/src/test/scala/nodejs/path/PathTest.scala @@ -0,0 +1,13 @@ +package io.scalajs.nodejs +package path + +import org.scalatest.FunSpec + +class PathTest extends FunSpec { + describe("Path") { + it("supports join()") { + assert(Path.win32.toNamespacedPath("c:\\foo\\bar") == "\\\\?\\c:\\foo\\bar") + assert(Path.posix.toNamespacedPath("c:\\foo\\bar") == "c:\\foo\\bar") + } + } +} diff --git a/app/nodejs-v8/src/test/scala/nodejs/path/PathTest.scala b/app/nodejs-v8/src/test/scala/nodejs/path/PathTest.scala index 4f3d65135..744a46042 100644 --- a/app/nodejs-v8/src/test/scala/nodejs/path/PathTest.scala +++ b/app/nodejs-v8/src/test/scala/nodejs/path/PathTest.scala @@ -36,7 +36,7 @@ class PathTest extends FunSpec { } it("supports join()") { - Path.join("/foo", "bar", "baz/asdf", "quux", "..") == "/foo/bar/baz/asdf" + assert(Path.join("/foo", "bar", "baz/asdf", "quux", "..") == "/foo/bar/baz/asdf") } }