UNPKG

1.06 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.copyFile = exports.exists = exports.rmdir = exports.stat = exports.mkdir = exports.access = exports.writeFile = exports.readFile = void 0;
4const util_1 = require("util");
5const fs = require("fs");
6const path_1 = require("path");
7exports.readFile = fs.promises.readFile;
8exports.writeFile = fs.promises.writeFile;
9exports.access = fs.promises.access;
10exports.mkdir = fs.promises.mkdir;
11exports.stat = fs.promises.stat;
12exports.rmdir = fs.promises.rmdir;
13async function exists(path) {
14 try {
15 await exports.access(path, fs.constants.F_OK);
16 return true;
17 }
18 catch {
19 return false;
20 }
21}
22exports.exists = exists;
23const cpFile = util_1.promisify(fs.copyFile);
24async function copyFile(src, dest) {
25 const dir = path_1.dirname(dest);
26 if (!(await exists(dir))) {
27 await exports.mkdir(dir, { recursive: true });
28 }
29 await cpFile(src, dest, fs.constants.COPYFILE_FICLONE);
30}
31exports.copyFile = copyFile;
32//# sourceMappingURL=fs.js.map
\No newline at end of file