@@ -14,7 +14,6 @@ import { isNonEmptyArray } from '@adobe/spacecat-shared-utils';
1414
1515import fs from 'fs' ;
1616import path from 'path' ;
17- import { fileURLToPath } from 'url' ;
1817import { say } from '../../utils/slack-utils.js' ;
1918
2019const TASK_TYPE = 'cwv-demo-suggestions-processor' ;
@@ -24,9 +23,6 @@ const INP = 'inp';
2423const DEMO = 'demo' ;
2524const MAX_CWV_DEMO_SUGGESTIONS = 2 ;
2625
27- const filename = fileURLToPath ( import . meta. url ) ;
28- const dirname = path . dirname ( filename ) ;
29-
3026/**
3127 * CWV thresholds for determining if metrics have issues
3228 */
@@ -77,9 +73,9 @@ function hasExistingIssues(suggestion) {
7773 */
7874function readStaticFile ( fileName , logger ) {
7975 try {
80- const filePath = path . resolve ( dirname , '../../../ static' , fileName ) ;
76+ const filePath = path . resolve ( process . cwd ( ) , 'static' , fileName ) ;
8177 const content = fs . readFileSync ( filePath , 'utf-8' ) ;
82- logger . debug ( `Successfully read content from ${ fileName } ` ) ;
78+ logger . debug ( `Successfully read content from ${ fileName } at ${ filePath } ` ) ;
8379 return content ;
8480 } catch ( error ) {
8581 logger . error ( `Error reading static file ${ fileName } : ${ error . message } ` ) ;
@@ -132,8 +128,8 @@ async function updateSuggestionWithGenericIssues(
132128
133129 let cwvReferenceSuggestions = { lcp : [ ] , cls : [ ] , inp : [ ] } ;
134130 try {
135- const jsonPath = path . resolve ( dirname , '../../../ static/aem-best-practices.json' ) ;
136- logger . info ( `Loading CWV reference suggestions from: ${ filename } , ${ dirname } , ${ jsonPath } ` ) ;
131+ const jsonPath = path . resolve ( process . cwd ( ) , 'static/aem-best-practices.json' ) ;
132+ logger . info ( `Loading CWV reference suggestions from: ${ jsonPath } ` ) ;
137133 const rawData = fs . readFileSync ( jsonPath , 'utf-8' ) ;
138134 cwvReferenceSuggestions = JSON . parse ( rawData ) ;
139135 await say ( env , logger , slackContext , `Loaded CWV reference suggestions from: ${ jsonPath } ` ) ;
0 commit comments