mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat(create-discord-bot): throw error if the directory is a file (#9719)
This commit is contained in:
@@ -35,9 +35,11 @@ export async function createDiscordBot({ typescript, javascript, directory }: Op
|
||||
throw error;
|
||||
});
|
||||
|
||||
// If a directory exists and it's not empty, throw an error.
|
||||
if (directoryStats.isDirectory() && (await readdir(root)).length > 0) {
|
||||
console.error(chalk.red(`The directory ${chalk.yellow(`"${directoryName}"`)} is not empty.`));
|
||||
// If the directory is actually a file or if it's not empty, throw an error.
|
||||
if (!directoryStats.isDirectory() || (await readdir(root)).length > 0) {
|
||||
console.error(
|
||||
chalk.red(`The directory ${chalk.yellow(`"${directoryName}"`)} is either not a directory or is not empty.`),
|
||||
);
|
||||
console.error(chalk.red(`Please specify an empty directory.`));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user