1 | "use strict";
|
2 |
|
3 | const { execSync } = require("child_process");
|
4 | const { internalModuleStat } = process.binding("fs");
|
5 | const { readdirSync, readFileSync, copyFileSync, writeFileSync } = require("fs");
|
6 |
|
7 | module.exports.write = function ({ path, contents, encoding }) {
|
8 | return writeFileSync(path, contents, encoding);
|
9 | };
|
10 |
|
11 | module.exports.copy = function ({ source, destination }) {
|
12 | return copyFileSync(source, destination);
|
13 | };
|
14 |
|
15 | module.exports.read = function read({ path, encoding }) {
|
16 | return readFileSync(path, encoding);
|
17 | };
|
18 |
|
19 | module.exports.readdir = function readdir({ path }) {
|
20 | return readdirSync(path);
|
21 | };
|
22 |
|
23 | module.exports.mkdirp = function mkdirp({ path }) {
|
24 | execSync(`mkdir -p ${JSON.stringify(path)}`);
|
25 | };
|
26 |
|
27 | module.exports.tstat = function tstat({ path }) {
|
28 | const type = internalModuleStat(path);
|
29 |
|
30 | if (type < 0) return "ENOENT";
|
31 |
|
32 | if (type === 0) return "file";
|
33 |
|
34 | if (type === 1) return "directory";
|
35 |
|
36 | throw new Error("Unknown Error");
|
37 | }; |
\ | No newline at end of file |