import { RecordOptions , SaveOptions } from './Plugin' ; const filename = ( path ) : string | undefined => { const startIndex = path . indexOf ( '\\' ) >= 0 ? path . lastIndexOf ( '\\' ) : path . lastIndexOf ( '/' ) ; let name = path . substring ( startIndex ) ; if ( name . indexOf ( '\\' ) === 0 || name . indexOf ( '/' ) === 0 ) { name = name . substring ( 1 ) ; } const startExtIndex = name . lastIndexOf ( '.' ) ; return name . substring ( 0 , startExtIndex ) ; } ; const harFileName = ( path ) : string | undefined => `${ filename ( path ) }.har` ; Cypress . Commands . add ( 'recordHar' , ( options ? ) : Cypress . Chainable => cy . task ( 'recordHar' , Object . assign ( { content : true } , options ) ) ) ; Cypress . Commands . add ( 'saveHar' , ( options ? ) : Cypress . Chainable => { const fallbackFileName = Cypress . spec . name ; const outDir = Cypress . env ( 'hars_folders' ) ?? './' ; options = Object . assign ( { outDir } , options , { fileName : harFileName ( options ?. fileName ?? fallbackFileName ) } ) ; return cy . task ( 'saveHar' , options ) ; } ) ;