import fs from 'fs' ; export const restoreClassChanges = ( writeLocation ) => { const fileExists = fs . existsSync ( writeLocation ) ; if ( ! fileExists ) return ; const customCode = [ ] ; let index = 0 ; let Stop = false ; fs . readFileSync ( writeLocation , 'utf-8' ) . split ( '\n' ) . reverse ( ) . forEach ( ( line ) => { if ( ! Stop && ( line . includes ( '// skip overwrite' ) || ( ! line . includes ( '}' ) && customCode . length === 0 ) || customCode . length > 0 ) ) { if ( line . includes ( '// skip overwrite' ) ) { Stop = true ; } customCode . push ( line ) ; index ++ ; } } ) ; return customCode . reverse ( ) . join ( '\n' ) . replace ( /\n$/ , '' ) ; } ;