Skip to content

Commit bccc56e

Browse files
committed
chore(prompt): revise prompt cmd
1 parent 58a437d commit bccc56e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

bin/prompt-command.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ const runCommand = (command, args) => {
2929
};
3030

3131
module.exports = function promptForInstallation(packages, ...args) {
32+
const nameOfPackage = "@webpack-cli/" + packages;
3233
let packageIsInstalled = false;
3334
try {
34-
require.resolve(packages);
35+
require.resolve(nameOfPackage);
3536
packageIsInstalled = true;
3637
} catch (err) {
3738
packageIsInstalled = false;
@@ -44,7 +45,6 @@ module.exports = function promptForInstallation(packages, ...args) {
4445
const isYarn = fs.existsSync(path.resolve(process.cwd(), "yarn.lock"));
4546

4647
const packageManager = isYarn ? "yarn" : "npm";
47-
const nameOfPackage = "@webpack-cli/" + packages;
4848
const options = ["install", "-D", nameOfPackage];
4949

5050
if (isYarn) {
@@ -74,7 +74,7 @@ module.exports = function promptForInstallation(packages, ...args) {
7474
if (packages === "serve") {
7575
return require(`@webpack-cli/${packages}`).serve();
7676
}
77-
return require(`@webpack-cli/${packages}`)(...args); //eslint-disable-line
77+
return require(nameOfPackage)(...args); //eslint-disable-line
7878
})
7979
.catch(error => {
8080
console.error(error);
@@ -92,6 +92,6 @@ module.exports = function promptForInstallation(packages, ...args) {
9292
}
9393
});
9494
} else {
95-
require(packages)(...args); // eslint-disable-line
95+
require(nameOfPackage)(...args); // eslint-disable-line
9696
}
9797
};

0 commit comments

Comments
 (0)