fix: usage `npx webpack`

This commit is contained in:
evilebottnawi 2021-06-07 17:34:01 +03:00
parent 5dd661cc39
commit 8203154a54
1 changed files with 20 additions and 5 deletions

View File

@ -32,13 +32,28 @@ const runCommand = (command, args) => {
* @returns {boolean} is the package installed?
*/
const isInstalled = packageName => {
try {
require.resolve(packageName);
if (process.versions.pnp) {
return true;
} catch (err) {
return false;
}
const path = require("path");
const fs = require("graceful-fs");
let dir = __dirname;
do {
try {
if (
fs.statSync(path.join(dir, "node_modules", packageName)).isDirectory()
) {
return true;
}
} catch (_error) {
// Nothing
}
} while (dir !== (dir = path.dirname(dir)));
return false;
};
/**