Skip to content

Commit

Permalink
fix(init): update prompt command
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabh3112 committed Mar 9, 2019
1 parent 4b130bb commit 1cab3cb
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions bin/prompt-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
const runCommand = (command, args) => {
const cp = require("child_process");
return new Promise((resolve, reject) => {
resolve();
const executedCommand = cp.spawn(command, args, {
stdio: "inherit",
shell: true
Expand Down Expand Up @@ -87,11 +86,20 @@ module.exports = function promptForInstallation(packages, ...args) {
//eslint-disable-next-line
runCommand(packageManager, options)
.then(result => {
pathForCmd = path.resolve(process.cwd(), "node_modules", "@webpack-cli", packages);
if (packages === "serve") {
return require(pathForCmd).default.serve();
if (packages === "init") {
runCommand("webpack-cli", ["init"])
.then(_=>{})
.catch(err => {
console.error(err);
process.exitCode = 1;
});
} else {
pathForCmd = path.resolve(process.cwd(), "node_modules", "@webpack-cli", packages);
if (packages === "serve") {
return require(pathForCmd).default.serve();
}
return require(pathForCmd).default(...args); //eslint-disable-line
}
return require(pathForCmd).default(...args); //eslint-disable-line
})
.catch(error => {
console.error(error);
Expand Down

0 comments on commit 1cab3cb

Please sign in to comment.