Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Overhaul path module #70

Merged
merged 1 commit into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) | |
Expand Down
12 changes: 8 additions & 4 deletions app/current/src/main/scala/io/scalajs/nodejs/path/Path.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.scalajs.nodejs.path

import com.thoughtworks.enableIf

import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport

Expand All @@ -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
Expand Down Expand Up @@ -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
}

/**
Expand Down
13 changes: 13 additions & 0 deletions app/nodejs-v10/src/test/scala/nodejs/path/PathTest.scala
Original file line number Diff line number Diff line change
@@ -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")
}
}
}
2 changes: 1 addition & 1 deletion app/nodejs-v8/src/test/scala/nodejs/path/PathTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

}
Expand Down