import fs from 'fs';
export function doesFileExist(file) {
    const statObject = getStatObject(file);
    return statObject && statObject.isFile();
}
export function doesDirectoryExist(directory) {
    const statObject = getStatObject(directory);
    return statObject && statObject.isDirectory();
}
export function createFolderIfItDoesNotExist(directory) {
    if (!directory) {
        throw new Error('A directory must be passed to be created.');
    }
    const statObject = getStatObject(directory);
    if (statObject && statObject.isFile()) {
        throw new Error(`The directory to create '${directory}' is a file.`);
    }
    fs.mkdirSync(directory, { recursive: true });
}
function getStatObject(file) {
    try {
        return fs.statSync(file);
    }
    catch (error) {
        return false;
    }
}
