From 1cab3cbc92234748b3e2f20d70f09d20212561f1 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Fri, 25 Jan 2019 20:27:07 +0530 Subject: [PATCH] fix(init): update prompt command --- bin/prompt-command.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/bin/prompt-command.js b/bin/prompt-command.js index bd38d320cfe..09a941950b5 100644 --- a/bin/prompt-command.js +++ b/bin/prompt-command.js @@ -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 @@ -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);