-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathfile-system.ts
More file actions
27 lines (20 loc) · 784 Bytes
/
file-system.ts
File metadata and controls
27 lines (20 loc) · 784 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
import { promises, unlink as fsUnlink, writeFileSync as fsWriteFileSync } from 'fs';
const { access: fsAccess, writeFile: fsWriteFile, readFile: fsReadFile, mkdir } = promises;
export function access(...args: Parameters<typeof fsAccess>) {
return fsAccess(...args);
}
export function writeFile(filepath: string, content: string) {
return fsWriteFile(filepath, content);
}
export function writeFileSync(filepath: string, content: string) {
return fsWriteFileSync(filepath, content);
}
export function readFile(filepath: string) {
return fsReadFile(filepath, 'utf-8');
}
export function unlinkFile(filePath: string, cb?: (err?: Error) => any): void {
fsUnlink(filePath, cb);
}
export function mkdirp(filePath: string) {
return mkdir(filePath, { recursive: true });
}