@ -198,9 +198,10 @@ class FileProvider {
/ * *
/ * *
* copy the folder recursively ( internal use )
* copy the folder recursively ( internal use )
* @ param { string } path is the folder to be copied over
* @ param { string } path is the folder to be copied over
* @ param { string } destination is the destination folder
* @ param { Function } visitFile is a function called for each visited files
* /
* /
_copyFolderToJsonInternal ( path ) {
_copyFolderToJsonInternal ( path , visitFile ) {
visitFile = visitFile || ( ( ) => { } )
return new Promise ( ( resolve , reject ) => {
return new Promise ( ( resolve , reject ) => {
const json = { }
const json = { }
path = this . removePrefix ( path )
path = this . removePrefix ( path )
@ -212,9 +213,10 @@ class FileProvider {
const file = { }
const file = { }
const curPath = ` ${ path } ${ path . endsWith ( '/' ) ? '' : '/' } ${ item } `
const curPath = ` ${ path } ${ path . endsWith ( '/' ) ? '' : '/' } ${ item } `
if ( window . remixFileSystem . statSync ( curPath ) . isDirectory ( ) ) {
if ( window . remixFileSystem . statSync ( curPath ) . isDirectory ( ) ) {
file . children = await this . _copyFolderToJsonInternal ( curPath )
file . children = await this . _copyFolderToJsonInternal ( curPath , visitFile )
} else {
} else {
file . content = window . remixFileSystem . readFileSync ( curPath , 'utf8' )
file . content = window . remixFileSystem . readFileSync ( curPath , 'utf8' )
visitFile ( { path : curPath , content : file . content } )
}
}
json [ curPath ] = file
json [ curPath ] = file
} )
} )
@ -231,10 +233,11 @@ class FileProvider {
/ * *
/ * *
* copy the folder recursively
* copy the folder recursively
* @ param { string } path is the folder to be copied over
* @ param { string } path is the folder to be copied over
* @ param { string } destination is the destination folder
* @ param { Function } visitFile is a function called for each visited files
* /
* /
copyFolderToJson ( path ) {
copyFolderToJson ( path , visitFile ) {
return this . _copyFolderToJsonInternal ( path )
visitFile = visitFile || ( ( ) => { } )
return this . _copyFolderToJsonInternal ( path , visitFile )
}
}
removeFile ( path ) {
removeFile ( path ) {