File tree Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -192,8 +192,8 @@ exports.supportFileCleanup = () => {
192
192
} ) ;
193
193
}
194
194
195
- const getAccessibilityCypressCommandEventListener = ( isJS ) => {
196
- return isJS ? (
195
+ const getAccessibilityCypressCommandEventListener = ( extName ) => {
196
+ return extName == 'js' ? (
197
197
`require('browserstack-cypress-cli/bin/accessibility-automation/cypress');`
198
198
) : (
199
199
`import 'browserstack-cypress-cli/bin/accessibility-automation/cypress'`
@@ -212,7 +212,7 @@ exports.setAccessibilityEventListeners = (bsConfig) => {
212
212
if ( ! file . includes ( 'commands.js' ) && ! file . includes ( 'commands.ts' ) ) {
213
213
const defaultFileContent = fs . readFileSync ( file , { encoding : 'utf-8' } ) ;
214
214
215
- let cypressCommandEventListener = getAccessibilityCypressCommandEventListener ( file . includes ( 'js' ) ) ;
215
+ let cypressCommandEventListener = getAccessibilityCypressCommandEventListener ( path . extname ( file ) ) ;
216
216
if ( ! defaultFileContent . includes ( cypressCommandEventListener ) ) {
217
217
let newFileContent = defaultFileContent +
218
218
'\n' +
Original file line number Diff line number Diff line change @@ -317,15 +317,18 @@ exports.setBrowserstackCypressCliDependency = (bsConfig) => {
317
317
318
318
exports . deleteSupportFileOrDir = ( fileOrDirPath ) => {
319
319
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
+ }
329
332
}
330
333
}
331
334
} catch ( err ) { }
You can’t perform that action at this time.
0 commit comments