mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +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;
|
throw error;
|
||||||
});
|
});
|
||||||
|
|
||||||
// If a directory exists and it's not empty, throw an error.
|
// If the directory is actually a file or if it's not empty, throw an error.
|
||||||
if (directoryStats.isDirectory() && (await readdir(root)).length > 0) {
|
if (!directoryStats.isDirectory() || (await readdir(root)).length > 0) {
|
||||||
console.error(chalk.red(`The directory ${chalk.yellow(`"${directoryName}"`)} is not empty.`));
|
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.`));
|
console.error(chalk.red(`Please specify an empty directory.`));
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user