@intlayer/chokidar
Version:
Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.
35 lines (33 loc) • 921 B
JavaScript
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
import { join } from "node:path";
//#region src/init/utils/fileSystem.ts
/**
* Helper to check if a file exists
*/
const exists = async (rootDir, filePath) => {
try {
await access(join(rootDir, filePath));
return true;
} catch {
return false;
}
};
/**
* Helper to read a file
*/
const readFileFromRoot = async (rootDir, filePath) => await readFile(join(rootDir, filePath), "utf8");
/**
* Helper to write a file
*/
const writeFileToRoot = async (rootDir, filePath, content) => await writeFile(join(rootDir, filePath), content, "utf8");
/**
* Helper to ensure a directory exists
*/
const ensureDirectory = async (rootDir, dirPath) => {
try {
await mkdir(join(rootDir, dirPath), { recursive: true });
} catch {}
};
//#endregion
export { ensureDirectory, exists, readFileFromRoot, writeFileToRoot };
//# sourceMappingURL=fileSystem.mjs.map