Skip to content

Commit dbff267

Browse files
authored
Support creation of 1+ names recipes rather than all of them (#28)
1 parent 3ffbae1 commit dbff267

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

recipes/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ npm run create
1010
```
1111

1212
This will overwrite all existing recipes. If you are happy with the changes, `git commit` them.
13+
14+
To recreate one or more named recipes rather than all of them use:
15+
```bash
16+
npm run create -- VanillaWebpack VanillaRspack
17+
```

recipes/src/runner.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,21 @@ import * as allRecipes from './recipes/typescript';
33

44
const writers: Writer[] = [new BashWriter(), new ReadmeWriter()];
55

6-
for (const cls of Object.values(allRecipes)) {
6+
let recipeNames = Object.keys(allRecipes);
7+
if (process.argv.length > 2) {
8+
recipeNames = process.argv.slice(2).map((arg) => arg + 'Recipe');
9+
10+
const unknownNames = recipeNames.filter(name => !(name in allRecipes));
11+
if (unknownNames.length > 0) {
12+
console.error("Unknown recipe name(s):", unknownNames.join(', '));
13+
process.exit(1)
14+
}
15+
}
16+
17+
console.log("Creating recipes for", recipeNames);
18+
19+
for (const recipeName of recipeNames) {
20+
const cls = allRecipes[recipeName];
721
const recipe: Recipe = new (cls as any)();
822
console.log(`Recipe ${recipe.type} ${recipe.framework} ${recipe.bundler}`);
923

0 commit comments

Comments
 (0)