@smushytaco/custompatch
Version:
Tool for patching buggy NPM packages instead of forking them
24 lines (21 loc) • 775 B
JavaScript
import fs from 'node:fs';
import path from 'pathe';
import pc from 'picocolors';
function pathNormalize(pathName) {
return path.normalize(path.sep === "/" ? pathName.replaceAll("\\", "/") : pathName.replaceAll("/", "\\\\"));
}
function ensureDirectoryExists(directoryPath) {
if (!fs.existsSync(directoryPath)) {
fs.mkdirSync(directoryPath, { recursive: true });
}
}
function readFileContent(filePath) {
try {
return fs.readFileSync(filePath, "utf8");
} catch (error) {
console.error(`${pc.redBright("ERROR:")} Failed to read file ${filePath} - ${error instanceof Error ? error.message : String(error)}`);
return "";
}
}
export { ensureDirectoryExists as e, pathNormalize as p, readFileContent as r };
//# sourceMappingURL=file-utilities.mjs.map