Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ulixee
GitHub Repository: ulixee/secret-agent
Path: blob/main/commons/fileUtils.ts
1028 views
1
import { promises as Fs } from 'fs';
2
import * as Os from 'os';
3
4
export async function existsAsync(path: string): Promise<boolean> {
5
try {
6
await Fs.access(path);
7
return true;
8
} catch (_) {
9
return false;
10
}
11
}
12
13
const homeDirReplace = new RegExp(Os.homedir(), 'g');
14
15
export function cleanHomeDir(str: string): string {
16
return str.replace(homeDirReplace, '~');
17
}
18
19