mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 13:03:31 +01:00
feat(create-discord-bot): allow certain files/folders to be included in the target directory (#11368)
* feat(create-discord-bot): allow empty git repositories
* feat(create-discord-bot): create a .gitignore for git repositories
* fix(create-discord-bot): correctly handle .git file edge case
* refactor(create-discord-bot): use next.js "is-folder-empty" utility
* refactor(create-discord-bot): combine checks
* revert: revert comment change
This reverts commit 2f8422e90d.
* feat(create-discord-bot): add .gitignore to templates
* docs(create-discord-bot): add source link to isFolderEmpty util
* docs(create-discord-bot): add @license JSDoc tag to license comment
---------
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import type { ExecException } from 'node:child_process';
|
||||
import { cp, mkdir, stat, readdir, readFile, writeFile } from 'node:fs/promises';
|
||||
import { cp, mkdir, stat, readFile, writeFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { styleText } from 'node:util';
|
||||
import type { PackageManager } from './helpers/packageManager.js';
|
||||
import { install } from './helpers/packageManager.js';
|
||||
import { GUIDE_URL } from './util/constants.js';
|
||||
import { isFolderEmpty } from './util/isFolderEmpty.js';
|
||||
|
||||
interface Options {
|
||||
directory: string;
|
||||
@@ -31,7 +32,7 @@ export async function createDiscordBot({ directory, installPackages, typescript,
|
||||
});
|
||||
|
||||
// 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() || !isFolderEmpty(root, directoryName)) {
|
||||
console.error(
|
||||
styleText(
|
||||
'red',
|
||||
|
||||
Reference in New Issue
Block a user