Skip to content

Commit cf450e4

Browse files
committed
chore: fix global path lookup
1 parent 2a43d44 commit cf450e4

3 files changed

Lines changed: 184 additions & 140 deletions

File tree

bin/prompt-command.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,20 @@ module.exports = function promptForInstallation(packages, ...args) {
3434
let pathForCmd;
3535
try {
3636
const path = require("path");
37+
const fs = require("fs");
3738
pathForCmd = path.resolve(
3839
process.cwd(),
3940
"node_modules",
4041
"@webpack-cli",
4142
packages
4243
);
43-
require.resolve(pathForCmd);
44+
if (!fs.existsSync(pathForCmd)) {
45+
const globalModules = require("global-modules");
46+
pathForCmd = globalModules + "/@webpack-cli/" + packages;
47+
require.resolve(pathForCmd);
48+
} else {
49+
require.resolve(pathForCmd);
50+
}
4451
packageIsInstalled = true;
4552
} catch (err) {
4653
packageIsInstalled = false;

0 commit comments

Comments
 (0)