Skip to content

Commit fd1811d

Browse files
committed
fixes
1 parent e91cb5a commit fd1811d

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

bin/accessibility-automation/helper.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ exports.supportFileCleanup = () => {
192192
});
193193
}
194194

195-
const getAccessibilityCypressCommandEventListener = (isJS) => {
196-
return isJS ? (
195+
const getAccessibilityCypressCommandEventListener = (extName) => {
196+
return extName == 'js' ? (
197197
`require('browserstack-cypress-cli/bin/accessibility-automation/cypress');`
198198
) : (
199199
`import 'browserstack-cypress-cli/bin/accessibility-automation/cypress'`
@@ -212,7 +212,7 @@ exports.setAccessibilityEventListeners = (bsConfig) => {
212212
if(!file.includes('commands.js') && !file.includes('commands.ts')) {
213213
const defaultFileContent = fs.readFileSync(file, {encoding: 'utf-8'});
214214

215-
let cypressCommandEventListener = getAccessibilityCypressCommandEventListener(file.includes('js'));
215+
let cypressCommandEventListener = getAccessibilityCypressCommandEventListener(path.extname(file));
216216
if(!defaultFileContent.includes(cypressCommandEventListener)) {
217217
let newFileContent = defaultFileContent +
218218
'\n' +

bin/helpers/helper.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,15 +317,18 @@ exports.setBrowserstackCypressCliDependency = (bsConfig) => {
317317

318318
exports.deleteSupportFileOrDir = (fileOrDirPath) => {
319319
try {
320-
if (fs.existsSync(fileOrDirPath)) {
321-
if (fs.lstatSync(fileOrDirPath).isDirectory()) {
322-
fs.readdirSync(fileOrDirPath).forEach((file) => {
323-
const currentPath = path.join(fileOrDirPath, file);
324-
fs.unlinkSync(currentPath);
325-
});
326-
fs.rmdirSync(fileOrDirPath);
327-
} else {
328-
fs.unlinkSync(fileOrDirPath);
320+
if (!fileOrDirPath.includes("..")) {
321+
const resolvedPath = path.resolve(fileOrDirPath);
322+
if (fs.existsSync(resolvedPath)) {
323+
if (fs.lstatSync(resolvedPath).isDirectory()) {
324+
fs.readdirSync(resolvedPath).forEach((file) => {
325+
const currentPath = path.join(resolvedPath, file);
326+
fs.unlinkSync(currentPath);
327+
});
328+
fs.rmdirSync(resolvedPath);
329+
} else {
330+
fs.unlinkSync(resolvedPath);
331+
}
329332
}
330333
}
331334
} catch(err) {}

0 commit comments

Comments
 (0)