Initial import NDC_1C
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ensureDir = ensureDir;
|
||||
exports.readJsonFile = readJsonFile;
|
||||
exports.writeJsonFile = writeJsonFile;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
function ensureDir(path) {
|
||||
if (!fs_1.default.existsSync(path)) {
|
||||
fs_1.default.mkdirSync(path, { recursive: true });
|
||||
}
|
||||
}
|
||||
function readJsonFile(path, fallback) {
|
||||
try {
|
||||
const raw = fs_1.default.readFileSync(path, "utf-8");
|
||||
return JSON.parse(raw);
|
||||
}
|
||||
catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
function writeJsonFile(path, value) {
|
||||
fs_1.default.writeFileSync(path, JSON.stringify(value, null, 2), "utf-8");
|
||||
}
|
||||
Reference in New Issue
Block a user