@@ -16,23 +16,28 @@ let _isGlobal: boolean | undefined
1616 */
1717export function currentProcessIsGlobal ( argv = process . argv ) : boolean {
1818 // If we are running tests, we need to disable the cache
19- if ( _isGlobal !== undefined && ! isUnitTest ( ) ) return _isGlobal
19+ try {
20+ if ( _isGlobal !== undefined && ! isUnitTest ( ) ) return _isGlobal
2021
21- // Path where the current project is (app/hydrogen)
22- const path = sniffForPath ( ) ?? cwd ( )
22+ // Path where the current project is (app/hydrogen)
23+ const path = sniffForPath ( ) ?? cwd ( )
2324
24- // Closest parent directory to contain a package.json file or node_modules directory
25- // https://docs.npmjs.com/cli/v8/commands/npm-prefix#description
26- const npmPrefix = execaSync ( 'npm' , [ 'prefix' ] , { cwd : path } ) . stdout . trim ( )
25+ // Closest parent directory to contain a package.json file or node_modules directory
26+ // https://docs.npmjs.com/cli/v8/commands/npm-prefix#description
27+ const npmPrefix = execaSync ( 'npm' , [ 'prefix' ] , { cwd : path } ) . stdout . trim ( )
2728
28- // From node docs: "The second element [of the array] will be the path to the JavaScript file being executed"
29- const binDir = argv [ 1 ] ?? ''
29+ // From node docs: "The second element [of the array] will be the path to the JavaScript file being executed"
30+ const binDir = argv [ 1 ] ?? ''
3031
31- // If binDir starts with npmPrefix, then we are running a local CLI
32- const isLocal = binDir . startsWith ( npmPrefix . trim ( ) )
32+ // If binDir starts with npmPrefix, then we are running a local CLI
33+ const isLocal = binDir . startsWith ( npmPrefix . trim ( ) )
3334
34- _isGlobal = ! isLocal
35- return _isGlobal
35+ _isGlobal = ! isLocal
36+ return _isGlobal
37+ // eslint-disable-next-line no-catch-all/no-catch-all
38+ } catch ( error ) {
39+ return false
40+ }
3641}
3742
3843/**
0 commit comments