Skip to content

Commit 1cab3cb

Browse files
committed
fix(init): update prompt command
1 parent 4b130bb commit 1cab3cb

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

bin/prompt-command.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
const runCommand = (command, args) => {
99
const cp = require("child_process");
1010
return new Promise((resolve, reject) => {
11-
resolve();
1211
const executedCommand = cp.spawn(command, args, {
1312
stdio: "inherit",
1413
shell: true
@@ -87,11 +86,20 @@ module.exports = function promptForInstallation(packages, ...args) {
8786
//eslint-disable-next-line
8887
runCommand(packageManager, options)
8988
.then(result => {
90-
pathForCmd = path.resolve(process.cwd(), "node_modules", "@webpack-cli", packages);
91-
if (packages === "serve") {
92-
return require(pathForCmd).default.serve();
89+
if (packages === "init") {
90+
runCommand("webpack-cli", ["init"])
91+
.then(_=>{})
92+
.catch(err => {
93+
console.error(err);
94+
process.exitCode = 1;
95+
});
96+
} else {
97+
pathForCmd = path.resolve(process.cwd(), "node_modules", "@webpack-cli", packages);
98+
if (packages === "serve") {
99+
return require(pathForCmd).default.serve();
100+
}
101+
return require(pathForCmd).default(...args); //eslint-disable-line
93102
}
94-
return require(pathForCmd).default(...args); //eslint-disable-line
95103
})
96104
.catch(error => {
97105
console.error(error);

0 commit comments

Comments
 (0)