Skip to content

Commit

Permalink
feat: webpack template generator for webpack repos
Browse files Browse the repository at this point in the history
  • Loading branch information
info-arnav committed Apr 22, 2024
1 parent 66ebe4e commit 100a4ce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/generators/src/init-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,27 @@ export default class InitGenerator<
public constructor(args: string | string[], opts: Z) {
super(args, opts);

const [, , ...restArgs] = args;
this.#parseArgs(restArgs);

this.dependencies = ["webpack", "webpack-cli"];
this.supportedTemplates = Object.keys(handlers);
}

#parseArgs(args: string[]): void {
const templateIndex = args.findIndex((arg) => arg === "--template");
if (
templateIndex !== -1 &&
templateIndex + 1 < args.length &&
args[templateIndex + 1] == "webpack"
) {
this.template = args[templateIndex + 1];
// now if the template is webpack, then we follow the execution of webpack-defaults ?
}
}

public async prompting(): Promise<void> {
this.template = await getTemplate.call(this);

await handlers[this.template as keyof typeof handlers].questions(this, Question);

// Handle installation of prettier
Expand Down
Empty file modified packages/webpack-cli/bin/cli.js
100755 → 100644
Empty file.

0 comments on commit 100a4ce

Please sign in to comment.