@baseplate-dev/sync
Version:
Library for syncing Baseplate descriptions
31 lines • 819 B
JavaScript
import fs from 'node:fs/promises';
/**
* Checks if a path exists
* @param fullPath - The path to check
* @returns Whether the path exists
*/
export async function pathExists(fullPath) {
return fs
.access(fullPath)
.then(() => true)
.catch(() => false);
}
/**
* Checks if a file exists
* @param filePath - The path to the file
* @returns Whether the file exists
*/
export async function fileExists(filePath) {
return fs
.stat(filePath)
.then((file) => file.isFile())
.catch(() => false);
}
/**
* Ensures a directory exists, creating it recursively if it doesn't
* @param directoryPath - The path to the directory
*/
export async function ensureDir(directoryPath) {
await fs.mkdir(directoryPath, { recursive: true });
}
//# sourceMappingURL=fs.js.map