Skip to content

Commit

Permalink
chore(prompt): revise prompt cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
evenstensberg committed May 17, 2018
1 parent 58a437d commit bccc56e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bin/prompt-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ const runCommand = (command, args) => {
};

module.exports = function promptForInstallation(packages, ...args) {
const nameOfPackage = "@webpack-cli/" + packages;
let packageIsInstalled = false;
try {
require.resolve(packages);
require.resolve(nameOfPackage);
packageIsInstalled = true;
} catch (err) {
packageIsInstalled = false;
Expand All @@ -44,7 +45,6 @@ module.exports = function promptForInstallation(packages, ...args) {
const isYarn = fs.existsSync(path.resolve(process.cwd(), "yarn.lock"));

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

if (isYarn) {
Expand Down Expand Up @@ -74,7 +74,7 @@ module.exports = function promptForInstallation(packages, ...args) {
if (packages === "serve") {
return require(`@webpack-cli/${packages}`).serve();
}
return require(`@webpack-cli/${packages}`)(...args); //eslint-disable-line
return require(nameOfPackage)(...args); //eslint-disable-line
})
.catch(error => {
console.error(error);
Expand All @@ -92,6 +92,6 @@ module.exports = function promptForInstallation(packages, ...args) {
}
});
} else {
require(packages)(...args); // eslint-disable-line
require(nameOfPackage)(...args); // eslint-disable-line
}
};

0 comments on commit bccc56e

Please sign in to comment.