Skip to content

Commit fe5e974

Browse files
debug
1 parent 41fac8d commit fe5e974

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

  • src/tasks/cwv-demo-suggestions-processor

src/tasks/cwv-demo-suggestions-processor/handler.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ const CLS = 'cls';
2222
const INP = 'inp';
2323
const DEMO = 'demo';
2424
const 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

Comments
 (0)