@@ -22,9 +22,6 @@ const CLS = 'cls';
2222const INP = 'inp' ;
2323const DEMO = 'demo' ;
2424const MAX_CWV_DEMO_SUGGESTIONS = 2 ;
25- const filename = fileURLToPath ( import . meta. url ) ;
26- const dirname = join ( filename , '..' , '..' , '..' ) ;
27- const CWV_SUGGESTIONS_FILE_PATH = join ( dirname , 'static' , 'aem-best-practices.json' ) ;
2825
2926/**
3027 * CWV thresholds for determining if metrics have issues
@@ -103,12 +100,20 @@ async function updateSuggestionWithGenericIssues(
103100 let cwvReferenceSuggestions = { } ;
104101
105102 try {
103+ const filename = fileURLToPath ( import . meta. url ) ;
104+ const dirname = join ( filename , '..' , '..' , '..' ) ;
105+ const CWV_SUGGESTIONS_FILE_PATH = join ( dirname , 'static' , 'aem-best-practices.json' ) ;
106106 logger . info ( `Loading CWV suggestions from: ${ CWV_SUGGESTIONS_FILE_PATH } ` ) ;
107+ // Debug: Log the path resolution for troubleshooting
108+ logger . debug ( 'Debug - filename:' , filename ) ;
109+ logger . debug ( 'Debug - dirname:' , dirname ) ;
110+ logger . debug ( 'Debug - CWV_SUGGESTIONS_FILE_PATH:' , CWV_SUGGESTIONS_FILE_PATH ) ;
111+
107112 const jsonContent = readFileSync ( CWV_SUGGESTIONS_FILE_PATH , 'utf8' ) ;
108113 cwvReferenceSuggestions = JSON . parse ( jsonContent ) ;
109114 logger . info ( `Successfully loaded CWV suggestions with keys: ${ Object . keys ( cwvReferenceSuggestions ) . join ( ', ' ) } ` ) ;
110115 } catch ( error ) {
111- logger . warn ( `Failed to load CWV reference suggestions from ${ CWV_SUGGESTIONS_FILE_PATH } : ${ error . message } ` ) ;
116+ logger . warn ( `Failed to load CWV reference suggestions: ${ error . message } ` ) ;
112117 await say ( env , logger , slackContext , `Failed to load CWV reference suggestions: ${ error . message } ` ) ;
113118 }
114119
0 commit comments