|
|
@ -91,6 +91,7 @@ class FileProvider { |
|
|
|
path = this.getPathFromUrl(path) || path // ensure we actually use the normalized path from here
|
|
|
|
path = this.getPathFromUrl(path) || path // ensure we actually use the normalized path from here
|
|
|
|
var unprefixedpath = this.removePrefix(path) |
|
|
|
var unprefixedpath = this.removePrefix(path) |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
console.log('getting', this.addSlash(unprefixedpath)) |
|
|
|
const content = await window.remixFileSystem.readFile(this.addSlash(unprefixedpath), 'utf8') |
|
|
|
const content = await window.remixFileSystem.readFile(this.addSlash(unprefixedpath), 'utf8') |
|
|
|
if (cb) cb(null, content) |
|
|
|
if (cb) cb(null, content) |
|
|
|
return content |
|
|
|
return content |
|
|
@ -207,12 +208,12 @@ class FileProvider { |
|
|
|
* @param {Function} visitFolder is a function called for each visited folders |
|
|
|
* @param {Function} visitFolder is a function called for each visited folders |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
async _copyFolderToJsonInternal (path, visitFile, visitFolder) { |
|
|
|
async _copyFolderToJsonInternal (path, visitFile, visitFolder) { |
|
|
|
/* visitFile = visitFile || (() => { }) |
|
|
|
visitFile = visitFile || (() => { }) |
|
|
|
visitFolder = visitFolder || (() => { }) |
|
|
|
visitFolder = visitFolder || (() => { }) |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
|
|
|
const json = {} |
|
|
|
const json = {} |
|
|
|
path = this.removePrefix(path) |
|
|
|
path = this.removePrefix(path) |
|
|
|
if (window.remixFileSystem.exists(this.addSlash(path))) { |
|
|
|
if (await window.remixFileSystem.exists(this.addSlash(path))) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const items = await window.remixFileSystem.readdir(this.addSlash(path)) |
|
|
|
const items = await window.remixFileSystem.readdir(this.addSlash(path)) |
|
|
|
visitFolder({ path }) |
|
|
|
visitFolder({ path }) |
|
|
@ -220,10 +221,10 @@ class FileProvider { |
|
|
|
for (const item of items) { |
|
|
|
for (const item of items) { |
|
|
|
const file = {} |
|
|
|
const file = {} |
|
|
|
const curPath = `${path}${path.endsWith('/') ? '' : '/'}${item}` |
|
|
|
const curPath = `${path}${path.endsWith('/') ? '' : '/'}${item}` |
|
|
|
if (await window.remixFileSystem.statExtended(curPath).isDirectory()) { |
|
|
|
if ((await window.remixFileSystem.statExtended(this.addSlash(curPath))).isDirectory()) { |
|
|
|
file.children = await this._copyFolderToJsonInternal(curPath, visitFile, visitFolder) |
|
|
|
file.children = await this._copyFolderToJsonInternal(curPath, visitFile, visitFolder) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
file.content = window.remixFileSystem.readFileSync(curPath, 'utf8') |
|
|
|
file.content = await window.remixFileSystem.readFile(this.addSlash(curPath), 'utf8') |
|
|
|
visitFile({ path: curPath, content: file.content }) |
|
|
|
visitFile({ path: curPath, content: file.content }) |
|
|
|
} |
|
|
|
} |
|
|
|
json[curPath] = file |
|
|
|
json[curPath] = file |
|
|
@ -231,11 +232,10 @@ class FileProvider { |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
console.log(e) |
|
|
|
console.log(e) |
|
|
|
return reject(e) |
|
|
|
throw new Error(e) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return resolve(json) |
|
|
|
return json |
|
|
|
}) */ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|