-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathNode.res
More file actions
132 lines (93 loc) · 3.48 KB
/
Copy pathNode.res
File metadata and controls
132 lines (93 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
module Fs = {
@module("node:fs") external existsSync: string => bool = "existsSync"
@module("node:fs") external readdirSync: string => array<string> = "readdirSync"
@module("node:fs")
external readFileSync: (string, @as(json`"utf8"`) _) => string = "readFileSync"
type stats
@module("node:fs") external statSync: string => stats = "statSync"
module Stats = {
@send external isDirectory: stats => bool = "isDirectory"
}
module Promises = {
@module("node:fs") @scope("promises")
external readFile: (string, @as(json`"utf8"`) _) => promise<string> = "readFile"
@module("node:fs") @scope("promises")
external writeFile: (string, string, @as(json`"utf8"`) _) => promise<unit> = "writeFile"
@module("node:fs") @scope("promises")
external appendFile: (string, string) => promise<unit> = "appendFile"
type cpOptions = {recursive?: bool}
@module("node:fs") @scope("promises")
external copyFile: (string, string) => promise<unit> = "copyFile"
@module("node:fs") @scope("promises")
external cp: (string, string, ~options: cpOptions=?) => promise<unit> = "cp"
@module("node:fs") @scope("promises")
external rename: (string, string) => promise<unit> = "rename"
type mkdirOptions = {recursive?: bool}
@module("node:fs") @scope("promises")
external mkdir: (string, ~options: mkdirOptions=?) => promise<unit> = "mkdir"
@module("node:fs") @scope("promises")
external unlink: string => promise<unit> = "unlink"
type rmOptions = {recursive?: bool, force?: bool}
@module("node:fs") @scope("promises")
external rm: (string, ~options: rmOptions=?) => promise<unit> = "rm"
}
}
module Path = {
@module("node:path")
external basename: string => string = "basename"
@module("node:path")
external dirname: string => string = "dirname"
@module("node:path") @variadic
external join: array<string> => string = "join"
@module("node:path") external join2: (string, string) => string = "join"
type parseResult = {
root: string,
dir: string,
base: string,
ext: string,
name: string,
}
@module("node:path") external parse: string => parseResult = "parse"
}
module Process = {
@scope("process") external argv: array<string> = "argv"
@scope("process") external chdir: string => unit = "chdir"
@scope("process") external cwd: unit => string = "cwd"
@scope("process") external exit: unit => unit = "exit"
@scope("process") external exitWithCode: int => unit = "exit"
}
module Assert = {
@module("node:assert/strict")
external strictEqual: ('a, 'a) => unit = "strictEqual"
@module("node:assert/strict")
external fail: string => unit = "fail"
}
module Test = {
@module("node:test")
external describe: (string, unit => unit) => unit = "describe"
@module("node:test")
external test: (string, unit => unit) => unit = "test"
@module("node:test")
external testAsync: (string, unit => promise<unit>) => unit = "test"
}
module Url = {
type t
@module("node:url") external fileURLToPath: t => string = "fileURLToPath"
@new external makeUnsafe: string => t = "URL"
@get external href: t => string = "href"
let make = string =>
try Some(makeUnsafe(string)) catch {
| Exn.Error(_exn) => None
}
}
module Os = {
type t
@module("node:os") external eol: string = "EOL"
}
module Promisified = {
module ChildProcess = {
type execResult = {stdout: string, stderr: string}
@module("./NodePromisified.mjs")
external exec: string => promise<execResult> = "exec"
}
}