Commit 7670a406 authored by yann300's avatar yann300

make sure workspace provider is removing the uneeded part of the paths

parent e4edff29
...@@ -196,11 +196,11 @@ class FileProvider { ...@@ -196,11 +196,11 @@ class FileProvider {
} }
/** /**
* copy the folder recursively * 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 {string} destination is the destination folder
*/ */
copyFolderToJson (path) { _copyFolderToJsonInternal (path) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const json = {} const json = {}
path = this.removePrefix(path) path = this.removePrefix(path)
...@@ -212,7 +212,7 @@ class FileProvider { ...@@ -212,7 +212,7 @@ 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.copyFolderToJson(curPath) file.children = await this._copyFolderToJsonInternal(curPath)
} else { } else {
file.content = window.remixFileSystem.readFileSync(curPath, 'utf8') file.content = window.remixFileSystem.readFileSync(curPath, 'utf8')
} }
...@@ -228,6 +228,15 @@ class FileProvider { ...@@ -228,6 +228,15 @@ class FileProvider {
}) })
} }
/**
* copy the folder recursively
* @param {string} path is the folder to be copied over
* @param {string} destination is the destination folder
*/
copyFolderToJson (path) {
return this._copyFolderToJsonInternal(path)
}
removeFile (path) { removeFile (path) {
path = this.removePrefix(path) path = this.removePrefix(path)
if (window.remixFileSystem.existsSync(path) && !window.remixFileSystem.statSync(path).isDirectory()) { if (window.remixFileSystem.existsSync(path) && !window.remixFileSystem.statSync(path).isDirectory()) {
......
...@@ -48,6 +48,13 @@ class WorkspaceFileProvider extends FileProvider { ...@@ -48,6 +48,13 @@ class WorkspaceFileProvider extends FileProvider {
}) })
} }
async copyFolderToJson (directory) {
let json = await super._copyFolderToJsonInternal(directory)
const regex = new RegExp(`.workspaces/${this.workspace}/`, 'g');
json = JSON.stringify(json).replace(regex, '')
return JSON.parse(json)
}
_normalizePath (path) { _normalizePath (path) {
if (!this.workspace) throw new Error('No workspace has been opened.') if (!this.workspace) throw new Error('No workspace has been opened.')
return path.replace(this.workspacesPath + '/' + this.workspace + '/', '') return path.replace(this.workspacesPath + '/' + this.workspace + '/', '')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment