Skip to content

Commit a26a790

Browse files
committed
chore: update
1 parent 550e1a7 commit a26a790

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

bin/webpack-dev-server.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,19 @@ const isInstalled = (packageName) => {
3939
try {
4040
// Importing here as done in runCommand()
4141
const { execSync } = require('child_process');
42-
const { resolve } = require('path');
43-
const { statSync } = require('fs');
4442

45-
const rootPath = execSync('npm root', { encoding: 'utf8' }).trimEnd();
46-
const packageStats = statSync(resolve(rootPath, `./${packageName}`));
47-
return packageStats.isDirectory();
43+
const command = `
44+
try {
45+
console.log(require.resolve('${packageName}'));
46+
} catch (err) {
47+
console.log('Not Found');
48+
}`;
49+
50+
const rootPath = execSync(`node -e "${command}"`, {
51+
encoding: 'utf8',
52+
}).trimEnd();
53+
54+
return rootPath !== 'Not Found';
4855
} catch (err) {
4956
return false;
5057
}

0 commit comments

Comments
 (0)