/
deps.ts
48 lines (44 loc) · 1.13 KB
/
deps.ts
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
export { EventEmitter } from 'https://deno.land/std@0.61.0/node/events.ts'
export { Buffer } from 'https://deno.land/std@0.61.0/node/buffer.ts'
export * as path from 'https://deno.land/std@0.61.0/path/mod.ts'
import * as _process from 'https://deno.land/std@0.61.0/node/process.ts'
export const spawn = (command: string, args: string[], opts?: any) => {
return Deno.run({
cmd: args && args.length ? [command, ...args] : [command]
})
}
const existsSync = (filePath: string) => {
try {
Deno.lstatSync(filePath);
return true;
} catch (err) {
if (err instanceof Deno.errors.NotFound) {
return false;
}
throw err;
}
}
export const fs = {
existsSync,
realpathSync: Deno.realPathSync
}
export const process = {
..._process,
get argv() {
return [Deno.execPath(), ...Deno.args];
},
mainModule: {
filename: Deno.mainModule
},
execPath: Deno.execPath(),
execArgv: Deno.args,
exitCode: 0,
platform: Deno.build.os === 'windows' ? 'win32' : Deno.build.os,
stdout: {
columns: 80,
write(str: string) {
Deno.stdout.writeSync(new TextEncoder().encode(str))
}
},
exit: Deno.exit
}