Skip to content

Commit 4c4bea5

Browse files
committed
debugging code added
1 parent 0d1bfc3 commit 4c4bea5

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

bin/accessibility-automation/helper.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,12 @@ exports.setAccessibilityEventListeners = (bsConfig) => {
244244
}
245245

246246
// Build the correct glob pattern
247-
const resolvedPath = path.resolve(process.cwd(), supportFilesData.supportFile);
248-
if (!resolvedPath.startsWith(process.cwd())) {
249-
throw new Error('Path traversal attempt detected');
250-
}
251-
const globPattern = supportFilesData.supportFile.startsWith('/')
252-
? process.cwd() + supportFilesData.supportFile
253-
: resolvedPath;
254-
247+
// const globPattern = supportFilesData.supportFile.startsWith('/')
248+
// ? process.cwd() + supportFilesData.supportFile
249+
// : path.resolve(process.cwd(), supportFilesData.supportFile);
250+
251+
const globPattern = process.cwd() + supportFilesData.supportFile;
252+
console.log(`Using glob pattern to find support files: ${globPattern}`);
255253
glob(globPattern, {}, (err, files) => {
256254
if(err) {
257255
logger.debug('EXCEPTION IN BUILD START EVENT : Unable to parse cypress support files');
@@ -261,26 +259,31 @@ exports.setAccessibilityEventListeners = (bsConfig) => {
261259
files.forEach(file => {
262260
try {
263261
const fileName = path.basename(file);
262+
console.log(`Found support file: ${file}`);
263+
console.log(`File name: ${fileName}`);
264264
if(['e2e.js', 'e2e.ts', 'component.ts', 'component.js'].includes(fileName) && !file.includes('node_modules')) {
265265

266266
const defaultFileContent = fs.readFileSync(file, {encoding: 'utf-8'});
267267
let cypressCommandEventListener = getAccessibilityCypressCommandEventListener(path.extname(file));
268-
268+
console.log(`Cypress command event listener: ${cypressCommandEventListener}`);
269269
if(!defaultFileContent.includes(cypressCommandEventListener)) {
270270
let newFileContent = defaultFileContent +
271271
'\n' +
272272
cypressCommandEventListener +
273273
'\n';
274274
fs.writeFileSync(file, newFileContent, {encoding: 'utf-8'});
275+
console.log(`Updated file content for ${file}: ${newFileContent}`);
275276
supportFileContentMap[file] = supportFilesData.cleanupParams ? supportFilesData.cleanupParams : defaultFileContent;
276277
}
277278
}
278279
} catch(e) {
280+
console.log(`Error updating file content for ${file}: ${e}`);
279281
logger.debug(`Unable to modify file contents for ${file} to set event listeners with error ${e}`, true, e);
280282
}
281283
});
282284
});
283285
} catch(e) {
286+
console.log(`Error updating file content for2 ${file}: ${e}`);
284287
logger.debug(`Unable to parse support files to set event listeners with error ${e}`, true, e);
285288
}
286289
}

bin/helpers/helper.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ exports.getSupportFiles = (bsConfig, isA11y) => {
390390
supportFile = userSupportFile[0];
391391
}
392392
} catch (err) {}
393-
if(supportFile && supportFile[0] != '/') supportFile = '/' + supportFile;
393+
if (supportFile && !path.isAbsolute(supportFile)) supportFile = '/' + supportFile;
394+
console.log(`Support file:123 ${supportFile}`);
394395
return {
395396
supportFile,
396397
cleanupParams: Object.keys(cleanupParams).length ? cleanupParams : null

0 commit comments

Comments
 (0)