Skip to content

Commit

Permalink
fix(generator): using configFile in configPath to get the config file…
Browse files Browse the repository at this point in the history
… name (#883)

* fix(generator): using configFile in configPath

Passing {configFile:configFile} to the env.run(generator) as second
argument in packages/utils/modify-config.ts and using this property in generator class to get the
configPath in generator class constructor in remove-generator.ts

* fix(lint): added semicolon

added semicolon in line 35

* fix(lint): remove blank line and added space

removed the blank line and added space in env.run method 's second argument.

* chore: removed the if-statement 

removed the if-statement and added space

* fix(init): refractor the init-generator to fix entry issue

Changed the init-generator code to fix the entry point issue when the
entry point was answered

* fix(init): refractor the init-generator to fix entry issue

Changed the init-generator code to fix the entry point issue when the
entry point was answered
  • Loading branch information
anikethsaha authored and ematipico committed May 24, 2019
1 parent 2b24329 commit fe31e65
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
10 changes: 4 additions & 6 deletions packages/generators/init-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,11 @@ export default class InitGenerator extends Generator {
.then(
(entryOptions: object | string): Promise<{}> => {
if (typeof entryOptions === "string" && entryOptions.length > 0) {
return this.prompt([
Input("outputType", "In which folder do you want to store your generated bundles? (dist):")
]);
}
if (entryOptions !== '""') {
this.configuration.config.webpackOptions.entry = entryOptions;
if (entryOptions !== "\"\"" && entryOptions !== "\'\'") {
this.configuration.config.webpackOptions.entry = entryOptions;
}
}

return this.prompt([
Input("outputType", "In which folder do you want to store your generated bundles? (dist):")
]);
Expand Down
8 changes: 2 additions & 6 deletions packages/generators/remove-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@ export default class RemoveGenerator extends Generator {
webpackOptions: {}
}
};

let configPath = path.resolve(process.cwd(), "webpack.config.js");
const { configFile } = opts;
let configPath = path.resolve(process.cwd(), configFile);
const webpackConfigExists = fs.existsSync(configPath);
if (!webpackConfigExists) {
configPath = null;
// end the generator stating webpack config not found or to specify the config
}
this.webpackOptions = require(configPath);
}

Expand Down
9 changes: 5 additions & 4 deletions packages/utils/modify-config-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function modifyHelperUtil(
logSymbols.error +
chalk.red(" ERROR ") +
chalk.cyan(configFile) +
" not found. Please specify a valid path to your webpack config like " +
" not found. Please specify a valid path to your webpack config like \n " +
chalk.white("$ ") +
chalk.cyan(`webpack-cli ${action} webpack.dev.js`) +
"\n"
Expand All @@ -87,10 +87,11 @@ export default function modifyHelperUtil(
}
};
}

env.registerStub(generator, generatorName);

env.run(generatorName)
.then(
env.run(generatorName, {
configFile
}).then(
(): void => {
let configModule: object;
try {
Expand Down

0 comments on commit fe31e65

Please sign in to comment.