-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
32 lines (28 loc) · 824 Bytes
/
Copy pathutils.js
File metadata and controls
32 lines (28 loc) · 824 Bytes
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
import child_process from "child_process";
import * as logger from "./logger.js";
import fs from "fs";
/**
*
* @export
* @return {Promise<number>}
*/
export async function execAsync(...args) {
return new Promise((resolve, reject) => {
let proc = child_process.spawn(...args);
// good logging
logger.info("Calling `" + args[0] + " " + args[1].join(" ") + "`");
proc.stdout.pipe(process.stdout);
proc.stderr.pipe(process.stderr);
process.stdin.pipe(proc.stdin);
proc.on("exit", resolve);
});
}
// check file exists async
export function existsAsync(filepath){
return new Promise((resolve, reject) => {
fs.access(filepath, fs.constants.F_OK, (err) => {
if(err) resolve(false);
else resolve(true);
});
});
}