UNPKG

@spotable/attio-sdk

Version:
27 lines (22 loc) 855 B
import * as fs from "node:fs"; import * as path from "node:path"; import logger from "./logger"; export function ensureDirectoryExists(directory: string) { const dirPath = path.resolve(directory); if (!fs.existsSync(dirPath)) { logger.debug(`Creating directory: ${dirPath}`); fs.mkdirSync(dirPath, { recursive: true }); } } export function writeGeneratedFile(directory: string, fileName: string, content: string) { const filePath = path.resolve(directory, fileName); logger.debug(`Writing generated file: ${filePath}`); fs.writeFileSync(filePath, content.trim()); } export function removeDirectoryRecursive(directory: string) { const dirPath = path.resolve(directory); if (fs.existsSync(dirPath)) { logger.debug(`Removing directory recursively: ${dirPath}`); fs.rmSync(dirPath, { recursive: true, force: true }); } }