UNPKG

@el3um4s/svelte-get-component-info

Version:
41 lines (40 loc) 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.checkFileExist = exports.readFileSvelte = void 0; const fs_1 = require("fs"); const to_try_1 = require("@el3um4s/to-try"); function readFileSvelte(nameFile) { const content = { error: { status: true, content: "file not read" }, content: { status: false, content: "" } }; if (checkFileExist(nameFile)) { const [result, error] = (0, to_try_1.toTry)(() => (0, fs_1.readFileSync)(nameFile)); if (!error && result) { const contentString = result.toString(); content.error = { status: false, content: "" }; content.content = { status: true, content: contentString }; } } else { content.error.content = `File "${nameFile}" not exist`; } return content; } exports.readFileSvelte = readFileSvelte; function checkFileExist(nameFile) { return (0, fs_1.existsSync)(nameFile); } exports.checkFileExist = checkFileExist;