@@ -5,20 +5,20 @@ import scala.scalajs.js
5
5
class NodeFile (path : String )(implicit fs : FS , nodePath : NodePath )
6
6
extends JsFile {
7
7
def this (path : String , child : String )(implicit fs : FS , nodePath : NodePath ) = {
8
- this (NodeFile . nodePath.join(path, child))
8
+ this (nodePath.join(path, child))
9
9
}
10
10
11
11
def delete (): Unit = {
12
- if (isDirectory()) NodeFile . fs.rmdirSync(path)
13
- else NodeFile . fs.unlinkSync(path)
12
+ if (isDirectory()) fs.rmdirSync(path)
13
+ else fs.unlinkSync(path)
14
14
}
15
15
16
16
def getAbsolutePath (): String = {
17
- NodeFile . fs.realpathSync(path)
17
+ fs.realpathSync(path)
18
18
}
19
19
20
20
def getName (): String = {
21
- NodeFile . nodePath.basename(path)
21
+ nodePath.basename(path)
22
22
}
23
23
24
24
def getPath (): String = {
@@ -27,7 +27,7 @@ class NodeFile(path: String)(implicit fs: FS, nodePath: NodePath)
27
27
28
28
def isDirectory (): Boolean = {
29
29
try {
30
- NodeFile . fs.lstatSync(path).isDirectory()
30
+ fs.lstatSync(path).isDirectory()
31
31
} catch {
32
32
// return false if the file does not exist
33
33
case e : Exception => false
@@ -38,9 +38,9 @@ class NodeFile(path: String)(implicit fs: FS, nodePath: NodePath)
38
38
path
39
39
.split(" /" )
40
40
.foldLeft(" " )((acc : String , x : String ) => {
41
- val new_acc = NodeFile . nodePath.join(acc, x)
41
+ val new_acc = nodePath.join(acc, x)
42
42
try {
43
- NodeFile . fs.mkdirSync(new_acc)
43
+ fs.mkdirSync(new_acc)
44
44
} catch {
45
45
case e : Exception =>
46
46
}
@@ -49,16 +49,16 @@ class NodeFile(path: String)(implicit fs: FS, nodePath: NodePath)
49
49
}
50
50
51
51
def listFiles (): Array [File ] = {
52
- val files = NodeFile . fs.readdirSync(path)
52
+ val files = fs.readdirSync(path)
53
53
val filesArray = new Array [File ](files.length)
54
54
for ((item, i) <- filesArray.zipWithIndex) {
55
- filesArray(i) = new File (NodeFile . nodePath.join(this .getPath(), files(i)))
55
+ filesArray(i) = new File (nodePath.join(this .getPath(), files(i)))
56
56
}
57
57
filesArray
58
58
}
59
59
60
60
def readFile (): String = {
61
- NodeFile . fs.readFileSync(path, js.Dynamic .literal(encoding = " utf-8" ))
61
+ fs.readFileSync(path, js.Dynamic .literal(encoding = " utf-8" ))
62
62
}
63
63
64
64
}
@@ -116,8 +116,5 @@ private[scalajssupport] object NodeFile extends NodeLikeFile {
116
116
}
117
117
118
118
private [scalajssupport] object JSDOMFile extends NodeLikeFile {
119
- lazy val require = {
120
- val process = js.Dynamic .global.Node .constructor(" return process" )()
121
- process.mainModule.require
122
- }
119
+ lazy val require = js.Dynamic .global.Node .constructor(" return require" )()
123
120
}
0 commit comments