Skip to content

Commit

Permalink
fix: usage npx webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Jun 7, 2021
1 parent 5dd661c commit 8203154
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions bin/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

/**
Expand Down

0 comments on commit 8203154

Please sign in to comment.