Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add no-install option #9604

Merged
merged 5 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/create-discord-bot/src/create-discord-bot.ts
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import { GUIDE_URL } from './util/constants.js';

interface Options {
directory: string;
javascript?: boolean;
noInstall?: boolean;
typescript?: boolean;
}

export async function createDiscordBot({ typescript, javascript, directory }: Options) {
export async function createDiscordBot({ typescript, directory, noInstall }: Options) {
if (!directory) {
console.error(chalk.red('Please specify the project directory.'));
process.exit(1);
Expand Down Expand Up @@ -76,8 +76,11 @@ export async function createDiscordBot({ typescript, javascript, directory }: Op
);
await writeFile('./package.json', newPackageJSON);

const packageManager = resolvePackageManager();
install(packageManager);
if (!noInstall) {
const packageManager = resolvePackageManager();
install(packageManager);
}

console.log(chalk.green('All done! Be sure to read through the discord.js guide for help on your journey.'));
console.log(`Link: ${chalk.cyan(GUIDE_URL)}`);
}
7 changes: 4 additions & 3 deletions packages/create-discord-bot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { createDiscordBot } from './create-discord-bot.js';
program
.description('Create a basic discord.js bot.')
.option('--directory', 'The directory where this will be created.')
.option('--no-install', 'Whether to not automatically install the packages.')
.option('--typescript', 'Whether to use the TypeScript template.')
.option('--javascript', 'Whether to use the JavaScript template.')
.parse();

let { typescript, javascript, directory } = program.opts();
// eslint-disable-next-line prefer-const
let { typescript, javascript, directory, 'no-install': noInstall } = program.opts();

if (!directory) {
directory = (
Expand All @@ -33,7 +35,6 @@ if (typescript === undefined && javascript === undefined) {
});

typescript = useTypescript;
javascript = !useTypescript;
}

await createDiscordBot({ typescript, javascript, directory });
await createDiscordBot({ typescript, directory, noInstall });
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export default {
async execute(client) {
console.log(`Ready! Logged in as ${client.user.tag}`);
},
} satisfies Event<'ready'>;
} satisfies Event<Events.ClientReady>;
Jiralite marked this conversation as resolved.
Show resolved Hide resolved