@@ -7,7 +7,7 @@ import { Logger } from '../logger.js';
77 * Get the runtime executable for the IDE, like WebStorm or VSCode
88 * @returns
99 */
10- export async function getRuntimeExecutableForIde ( ) {
10+ export async function getRuntimeExecutableForIde ( allowGlobal = true ) {
1111 let runtimeExecutable : string | undefined ;
1212 const localRuntimeExecutable = '${workspaceFolder}/node_modules/.bin/lld' ;
1313
@@ -19,68 +19,69 @@ export async function getRuntimeExecutableForIde() {
1919 ) ;
2020
2121 //if installed locally
22- if ( moduleDirname . startsWith ( '/home/' ) ) {
23- Logger . verbose ( 'Lambda Live Debugger is installed locally' ) ;
24- // check if file exists
25- try {
26- Logger . verbose (
27- 'Checking local folder for runtimeExecutable setting for VsCode configuration' ,
28- localFolder ,
29- ) ;
30- await fs . access ( localFolder , fs . constants . F_OK ) ;
31- runtimeExecutable = localRuntimeExecutable ;
32- } catch {
33- // Not found
34- }
35- } else {
36- Logger . verbose ( 'Lambda Live Debugger is installed globally' ) ;
22+ Logger . verbose ( 'Lambda Live Debugger is installed locally' ) ;
23+ try {
24+ Logger . verbose (
25+ 'Checking local folder for runtimeExecutable setting for VsCode configuration' ,
26+ localFolder ,
27+ ) ;
28+ await fs . access ( localFolder , fs . constants . F_OK ) ;
29+ runtimeExecutable = localRuntimeExecutable ;
30+ } catch {
31+ // Not found
3732 }
3833
3934 if ( ! runtimeExecutable ) {
40- Logger . verbose (
41- `Setting absolute path for runtimeExecutable setting for VsCode configuration` ,
42- ) ;
43- const localFolderSubfolder = path . resolve ( 'node_modules/.bin/lld' ) ;
44- const globalModule1 = path . join ( moduleDirname , '..' , '..' , '.bin/lld' ) ;
45- const globalModule2 = path . join ( moduleDirname , '..' , '..' , 'bin/lld' ) ;
46- const globalModule3 = path . join (
47- moduleDirname ,
48- '..' ,
49- '..' ,
50- '..' ,
51- '..' ,
52- 'bin/lld' ,
53- ) ;
54- const possibleFolders = {
55- [ localFolder ] : '${workspaceFolder}/node_modules/.bin/lld' ,
56- [ localFolderSubfolder ] : localFolderSubfolder ,
57- [ globalModule1 ] : globalModule1 ,
58- [ globalModule2 ] : globalModule2 ,
59- [ globalModule3 ] : globalModule3 ,
60- } ;
35+ Logger . verbose ( 'Lambda Live Debugger is installed globally' ) ;
6136
62- Logger . verbose (
63- `Checking the following possible folders for lld executable:` ,
64- JSON . stringify ( possibleFolders , null , 2 ) ,
65- ) ;
37+ if ( allowGlobal ) {
38+ Logger . verbose (
39+ `Setting absolute path for runtimeExecutable setting for VsCode configuration` ,
40+ ) ;
41+ const localFolderSubfolder = path . resolve ( 'node_modules/.bin/lld' ) ;
42+ const globalModule1 = path . join ( moduleDirname , '..' , '..' , '.bin/lld' ) ;
43+ const globalModule2 = path . join ( moduleDirname , '..' , '..' , 'bin/lld' ) ;
44+ const globalModule3 = path . join (
45+ moduleDirname ,
46+ '..' ,
47+ '..' ,
48+ '..' ,
49+ '..' ,
50+ 'bin/lld' ,
51+ ) ;
52+ const possibleFolders = {
53+ [ localFolder ] : '${workspaceFolder}/node_modules/.bin/lld' ,
54+ [ localFolderSubfolder ] : localFolderSubfolder ,
55+ [ globalModule1 ] : globalModule1 ,
56+ [ globalModule2 ] : globalModule2 ,
57+ [ globalModule3 ] : globalModule3 ,
58+ } ;
59+
60+ Logger . verbose (
61+ `Checking the following possible folders for lld executable:` ,
62+ JSON . stringify ( possibleFolders , null , 2 ) ,
63+ ) ;
6664
67- // check each possible folder and set the runtimeExecutable
68- for ( const folder in possibleFolders ) {
69- try {
70- //Logger.log("Checking folder", folder);
71- await fs . access ( folder , fs . constants . F_OK ) ;
72- runtimeExecutable = possibleFolders [ folder ] ;
73- Logger . verbose ( `Found folder with lld executable: ${ folder } ` ) ;
74- break ;
75- } catch {
76- // Not found
65+ // check each possible folder and set the runtimeExecutable
66+ for ( const folder in possibleFolders ) {
67+ try {
68+ //Logger.log("Checking folder", folder);
69+ await fs . access ( folder , fs . constants . F_OK ) ;
70+ runtimeExecutable = possibleFolders [ folder ] ;
71+ Logger . verbose ( `Found folder with lld executable: ${ folder } ` ) ;
72+ break ;
73+ } catch {
74+ // Not found
75+ }
7776 }
78- }
7977
80- if ( ! runtimeExecutable ) {
81- Logger . error (
82- `Could not find lld executable. Please check your IDE debugger settings.` ,
83- ) ;
78+ if ( ! runtimeExecutable ) {
79+ Logger . error (
80+ `Could not find lld executable. Please check your IDE debugger settings.` ,
81+ ) ;
82+ }
83+ } else {
84+ return null ;
8485 }
8586 }
8687
0 commit comments