|
@@ -0,0 +1,52 @@
|
|
1
|
+// Copyright 2016 wkh237@github. All rights reserved.
|
|
2
|
+// Use of this source code is governed by a MIT-style license that can be
|
|
3
|
+// found in the LICENSE file.
|
|
4
|
+// @flow
|
|
5
|
+import Log from '../utils/log'
|
|
6
|
+import path from 'path-parse'
|
|
7
|
+const log = new Log('node-path')
|
|
8
|
+
|
|
9
|
+log.level(3)
|
|
10
|
+log.info('node-path polyfill loaded')
|
|
11
|
+
|
|
12
|
+const sep = '/'
|
|
13
|
+
|
|
14
|
+function basename(str:string):string {
|
|
15
|
+ return path.parse(str).base
|
|
16
|
+}
|
|
17
|
+
|
|
18
|
+function dirname(str:string):string {
|
|
19
|
+ return path.parse(str).dir
|
|
20
|
+}
|
|
21
|
+
|
|
22
|
+function extname(str:string):string {
|
|
23
|
+ return path.parse(str).ext
|
|
24
|
+}
|
|
25
|
+
|
|
26
|
+function format(args:any):string {
|
|
27
|
+ // TODO :
|
|
28
|
+}
|
|
29
|
+
|
|
30
|
+function isAbsolute(str:string):boolean {
|
|
31
|
+ // TODO :
|
|
32
|
+ return true
|
|
33
|
+}
|
|
34
|
+
|
|
35
|
+function join(arr:Array):string {
|
|
36
|
+ // TODO : error handling and type checking
|
|
37
|
+ return arr.join('')
|
|
38
|
+}
|
|
39
|
+
|
|
40
|
+function normalize(str:string):string {
|
|
41
|
+ // TODO
|
|
42
|
+ return str
|
|
43
|
+}
|
|
44
|
+
|
|
45
|
+// since nodejs modules uses es5 export by default, we should use es5 export here
|
|
46
|
+export {
|
|
47
|
+ extname,
|
|
48
|
+ dirname,
|
|
49
|
+ basename,
|
|
50
|
+ // TODOs
|
|
51
|
+ normalize,
|
|
52
|
+}
|