File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -39,12 +39,19 @@ const isInstalled = (packageName) => {
39
39
try {
40
40
// Importing here as done in runCommand()
41
41
const { execSync } = require ( 'child_process' ) ;
42
- const { resolve } = require ( 'path' ) ;
43
- const { statSync } = require ( 'fs' ) ;
44
42
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' ;
48
55
} catch ( err ) {
49
56
return false ;
50
57
}
You can’t perform that action at this time.
0 commit comments