Skip to content

Commit

Permalink
misc(init-generator): improve types & defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
misterdev committed May 28, 2019
1 parent 9856bab commit fb23aa4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion INIT.md
@@ -1,6 +1,6 @@
# webpack-cli init

`webpack-cli init` is used to initialize `webpack` projects quickly by scaffolding configuration and a runnable project with all the dependencies based on the user preferences.
`webpack-cli init` is used to initialize `webpack` projects quickly by scaffolding configuration and creating a runnable project with all the dependencies based on the user preferences.

## Initial Setup

Expand Down
12 changes: 8 additions & 4 deletions packages/generators/init-generator.ts
Expand Up @@ -151,15 +151,19 @@ export default class InitGenerator extends Generator {
return this.prompt([
Confirm("multiEntries", "Will your application have multiple bundles?", false),
])
.then((multiEntriesAnswer: any) =>
.then((multiEntriesAnswer: {
multiEntries: boolean,
}) =>
entryQuestions(self, multiEntriesAnswer.multiEntries),
)
.then((entryOption: object | string) => {
if (typeof entryOption === "string" && entryOption.length > 0) {
this.configuration.config.webpackOptions.entry = `${entryOption}`;
} else if (typeof entryOption === "object") {
this.configuration.config.webpackOptions.entry = entryOption;
}
})
.then((_: void) =>
.then(() =>
this.prompt([
Input(
"outputDir",
Expand Down Expand Up @@ -191,7 +195,7 @@ export default class InitGenerator extends Generator {
`path.resolve(__dirname, '${outputDirAnswer.outputDir}')`;
}
})
.then((_: void) =>
.then(() =>
this.prompt([
Confirm("useBabel", "Will you be using ES2015?"),
]),
Expand All @@ -210,7 +214,7 @@ export default class InitGenerator extends Generator {
);
}
})
.then((_: void) =>
.then(() =>
this.prompt([
List("stylingType", "Will you use one of the below CSS solutions?", [
"No",
Expand Down
2 changes: 1 addition & 1 deletion packages/generators/utils/entry.ts
Expand Up @@ -104,7 +104,7 @@ export default function entry(self: CustomGenerator, multiEntries: boolean): Pro
`${entryProp}`,
`What is the location of "${entryProp}"?`,
validate,
`./src/${entryProp}`,
`src/${entryProp}`,
),
]),
).then((entryPropAnswer: object): object => {
Expand Down

0 comments on commit fb23aa4

Please sign in to comment.