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 = () => {
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' +
Original file line number Diff line number Diff line change @@ -317,15 +317,18 @@ exports.setBrowserstackCypressCliDependency = (bsConfig) => {
317317
318318exports . 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 ) { }
You can’t perform that action at this time.
0 commit comments