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

Commit 0b80fad

Browse files
authored
Merge pull request #70 from exoego/path
Overhaul path module
2 parents 3f1790b + ce9c29a commit 0b80fad

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The following core Node.js modules (v8.7.0+) have been implemented:
3535
| [https](https://nodejs.org/api/https.html) | |
3636
| [net](https://nodejs.org/api/net.html) | |
3737
| [os](https://nodejs.org/api/os.html) | :heavy_check_mark: |
38-
| [path](https://nodejs.org/api/path.html) | |
38+
| [path](https://nodejs.org/api/path.html) | :heavy_check_mark: |
3939
| [process](https://nodejs.org/api/process.html) | |
4040
| [querystring](https://nodejs.org/api/querystring.html) | :heavy_check_mark: |
4141
| [readline](https://nodejs.org/api/readline.html) | |

app/current/src/main/scala/io/scalajs/nodejs/path/Path.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.scalajs.nodejs.path
22

3+
import com.thoughtworks.enableIf
4+
35
import scala.scalajs.js
46
import scala.scalajs.js.annotation.JSImport
57

@@ -18,22 +20,22 @@ trait Path extends js.Object {
1820
/**
1921
* The platform-specific path delimiter, ';' or ':'.
2022
*/
21-
def delimiter: String = js.native
23+
val delimiter: String = js.native
2224

2325
/**
2426
* Provide access to aforementioned path methods but always interact in a posix compatible way.
2527
*/
26-
def posix: Path = js.native
28+
val posix: Path = js.native
2729

2830
/**
2931
* The platform-specific file separator, '\\' or '/'.
3032
*/
31-
def sep: String = js.native
33+
val sep: String = js.native
3234

3335
/**
3436
* Provide access to aforementioned path methods but always interact in a win32 compatible way.
3537
*/
36-
def win32: Path = js.native
38+
val win32: Path = js.native
3739

3840
/////////////////////////////////////////////////////////////////////////////////
3941
// Methods
@@ -133,6 +135,8 @@ trait Path extends js.Object {
133135
*/
134136
def resolve(args: String*): String = js.native
135137

138+
@enableIf(io.scalajs.nodejs.CompilerSwitches.gteNodeJs10)
139+
def toNamespacedPath(path: String): String = js.native
136140
}
137141

138142
/**
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package io.scalajs.nodejs
2+
package path
3+
4+
import org.scalatest.FunSpec
5+
6+
class PathTest extends FunSpec {
7+
describe("Path") {
8+
it("supports join()") {
9+
assert(Path.win32.toNamespacedPath("c:\\foo\\bar") == "\\\\?\\c:\\foo\\bar")
10+
assert(Path.posix.toNamespacedPath("c:\\foo\\bar") == "c:\\foo\\bar")
11+
}
12+
}
13+
}

app/nodejs-v8/src/test/scala/nodejs/path/PathTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class PathTest extends FunSpec {
3636
}
3737

3838
it("supports join()") {
39-
Path.join("/foo", "bar", "baz/asdf", "quux", "..") == "/foo/bar/baz/asdf"
39+
assert(Path.join("/foo", "bar", "baz/asdf", "quux", "..") == "/foo/bar/baz/asdf")
4040
}
4141

4242
}

0 commit comments

Comments
 (0)