isaacscript
Version:
A command line tool for managing Isaac mods written in TypeScript.
22 lines • 942 B
JavaScript
import chalk from "chalk";
import { deleteFileOrDirectory, fatalError, fileOrDirectoryExists, isDirectory, } from "complete-node";
import { CWD } from "../../constants.js";
import { getInputYesNo } from "../../prompt.js";
export async function checkIfProjectPathExists(projectPath, yes) {
if (projectPath === CWD || !fileOrDirectoryExists(projectPath)) {
return;
}
const fileType = isDirectory(projectPath) ? "directory" : "file";
if (yes) {
deleteFileOrDirectory(projectPath);
console.log(`Deleted ${fileType}: ${chalk.green(projectPath)}`);
return;
}
console.log(`A ${fileType} already exists with a name of: ${chalk.green(projectPath)}`);
const shouldDelete = await getInputYesNo("Do you want me to delete it?");
if (!shouldDelete) {
fatalError("Ok then. Goodbye.");
}
deleteFileOrDirectory(projectPath);
}
//# sourceMappingURL=checkIfProjectPathExists.js.map