Files
test-repo/scripts/build/util.js
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
575 B
JavaScript
Raw Normal View History

2018-05-24 15:30:45 -03:00
"use strict";
const fs = require("fs");
2020-01-14 23:30:18 +08:00
const { promisify } = require("util");
2018-05-24 15:30:45 -03:00
const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);
async function readJson(file) {
const data = await readFile(file);
return JSON.parse(data);
}
function writeJson(file, content) {
content = JSON.stringify(content, null, 2);
return writeFile(file, content);
}
2018-05-29 00:22:59 -06:00
async function copyFile(from, to) {
const data = await readFile(from);
return writeFile(to, data);
}
2018-05-24 15:30:45 -03:00
module.exports = {
readJson,
2018-05-29 00:22:59 -06:00
writeJson,
copyFile,
readFile,
writeFile,
2018-05-24 15:30:45 -03:00
};