Skip to content

Commit

Permalink
fix(generator): fixed the support of native plugins in add command
Browse files Browse the repository at this point in the history
refractored the code to fix the error of supporting the native plugin in
add-generator. removed the toLowerCase() method, added the logic for
more general plugin name from the input
  • Loading branch information
anikethsaha committed Jun 4, 2019
1 parent 6ee3c0b commit 123a150
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/generators/add-generator.ts
Expand Up @@ -291,6 +291,13 @@ export default class AddGenerator extends Generator {
* find the names of each natively plugin and check if it matches
*/
if (action === "plugins") {
let answeredPluginName = answerToAction.actionAnswer
let isPrefixPresent = /webpack./.test(answeredPluginName);
if( isPrefixPresent ){
answeredPluginName = answeredPluginName.replace("webpack.","").trim()
}else{
answeredPluginName = answeredPluginName.trim()
}
const pluginExist: string = glob
.sync(["node_modules/webpack/lib/*Plugin.js", "node_modules/webpack/lib/**/*Plugin.js"])
.map(
Expand All @@ -300,7 +307,7 @@ export default class AddGenerator extends Generator {
.pop()
.replace(".js", "")
)
.find((p: string): boolean => p.toLowerCase().indexOf(answerToAction.actionAnswer) >= 0);
.find((p: string): boolean => p.indexOf(answeredPluginName) >= 0);

if (pluginExist) {
this.configuration.config.item = pluginExist;
Expand All @@ -315,8 +322,7 @@ export default class AddGenerator extends Generator {
.split("/")
.pop()
.replace(".json", "")
.toLowerCase()
.indexOf(answerToAction.actionAnswer) >= 0
.indexOf(answeredPluginName) >= 0
);
if (pluginsSchemaPath) {
const constructorPrefix: string =
Expand Down

0 comments on commit 123a150

Please sign in to comment.