import * as filesystem from 'fs-extra' ; import { Main } from "../main" ; /**
 * The [[FilesBuilder]] class allows you to manage the generation, migration, and everything necessary to run the [[ContentGenerate]]
 */ export class FilesBuilder { /**
     * Location of the file where the project will be built
     */ public readonly directory : string ; param directory constructor ( directory ) { this . directory = directory ; } return public init = async ( ) : Promise < void | never > => { filesystem . exists ( this . directory , ( exists ) => { if ( exists ) filesystem . remove ( this . directory , ( ) => console . log ( "File deleted successfully, Start generate process." ) ) ; } ) ; await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ; return filesystem . ensureDir ( this . directory ) . then ( ( response ) => { if ( response !== undefined ) Main . onFolderGenerate ( response ) ; } ) ; } ; param data return public category = ( data ) : void => { for ( let category in data ) filesystem . ensureFile ( this . directory + "/" + category . toString ( ) + ".lua" ) . then ( ( ) => { console . info ( 'Create file successfully : ' + category . toString ( ) ) ; } ) . catch ( error => { console . error ( error ) ; } ) ; } ; param stats param files param data param nativeName return public update = ( stats , files , data , nativeName ) : void => { filesystem . appendFile ( this . directory + "/" + files + ".lua" , data , ( error ) => { if ( error ) console . error ( "can't update file" + files ) ; Main . onFileUpdate ( stats , files , nativeName ) ; } ) ; } ; }