-
-
Notifications
You must be signed in to change notification settings - Fork 621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cli(refactor): improve folder structure #371
Changes from all commits
dc71c53
8e786fe
20f15b0
ed679cf
c4bb9f9
e3c8fd8
d0e6bdb
5721513
80161f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
"use strict"; | ||
|
||
const makeLoaderName = require("./loader-generator").makeLoaderName; | ||
const { makeLoaderName } = require("./loader-generator"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I love these changes ❤️ |
||
|
||
describe("makeLoaderName", () => { | ||
it("should kebab-case loader name and append '-loader'", () => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
"use strict"; | ||
|
||
const path = require("path"); | ||
|
||
/** | ||
* | ||
* First function to be called after running a flag. This is a check, | ||
|
@@ -14,50 +12,10 @@ const path = require("path"); | |
*/ | ||
|
||
module.exports = function initialize(command, args) { | ||
const popArgs = args ? args.slice(2).pop() : null; | ||
switch (command) { | ||
case "init": { | ||
const initPkgs = args.slice(2).length === 1 ? [] : [popArgs]; | ||
//eslint-disable-next-line | ||
return require("./commands/init.js")(initPkgs); | ||
} | ||
case "migrate": { | ||
const filePaths = args.slice(2).length === 1 ? [] : [popArgs]; | ||
if (!filePaths.length) { | ||
throw new Error("Please specify a path to your webpack config"); | ||
} | ||
const inputConfigPath = path.resolve(process.cwd(), filePaths[0]); | ||
//eslint-disable-next-line | ||
return require("./commands/migrate.js")(inputConfigPath, inputConfigPath); | ||
} | ||
case "add": { | ||
//eslint-disable-next-line | ||
return require("./commands/add")(); | ||
} | ||
case "remove": { | ||
//eslint-disable-next-line | ||
return require("./commands/remove")(); | ||
} | ||
case "update": { | ||
return require("./commands/update")(); | ||
} | ||
case "serve": { | ||
return require("./commands/serve").serve(); | ||
} | ||
case "make": { | ||
return require("./commands/make")(); | ||
} | ||
case "generate-loader": { | ||
return require("./generate-loader/index.js")(); | ||
} | ||
case "generate-plugin": { | ||
return require("./generate-plugin/index.js")(); | ||
} | ||
case "info": { | ||
return require("./commands/info.js")(); | ||
} | ||
default: { | ||
throw new Error(`Unknown command ${command} found`); | ||
} | ||
if (!command) { | ||
throw new Error(`Unknown command ${command} found`); | ||
} else if (command === "serve") { | ||
return require(`./commands/${command}`).serve(); | ||
} | ||
return require(`./commands/${command}`)(...args); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would throw an error no file found. Are we OK with this? Or do we want to throw a better error message? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, we've defined all the commands in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we put this |
||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we merge this together?