|
|
|
@ -38,7 +38,7 @@ const createError = (err) => { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class FileManager extends Plugin { |
|
|
|
|
constructor (editor) { |
|
|
|
|
constructor (editor, appManager) { |
|
|
|
|
super(profile) |
|
|
|
|
this.openedFiles = {} // list all opened files
|
|
|
|
|
this.events = new EventEmitter() |
|
|
|
@ -46,6 +46,7 @@ class FileManager extends Plugin { |
|
|
|
|
this._components = {} |
|
|
|
|
this._components.compilerImport = new CompilerImport() |
|
|
|
|
this._components.registry = globalRegistry |
|
|
|
|
this.appManager = appManager |
|
|
|
|
this.init() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -493,6 +494,36 @@ class FileManager extends Plugin { |
|
|
|
|
return this._deps.filesProviders['browser'] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// returns the list of directories inside path
|
|
|
|
|
dirList (path) { |
|
|
|
|
const dirPaths = [] |
|
|
|
|
const collectList = (path) => { |
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
if (this.isDirectory(path)) { |
|
|
|
|
this.readdir(path).then((ls) => { |
|
|
|
|
const promises = Object.keys(ls).map((item, index) => { |
|
|
|
|
const root = (path.indexOf('/') === -1) ? path : path.substr(0, path.indexOf('/')) |
|
|
|
|
const curPath = `${root}/${item}` // adding 'browser' or 'localhost'
|
|
|
|
|
if (ls[item].isDirectory && !dirPaths.includes(curPath)) { |
|
|
|
|
dirPaths.push(curPath) |
|
|
|
|
resolve(dirPaths) |
|
|
|
|
} |
|
|
|
|
return new Promise((resolve, reject) => { resolve() }) |
|
|
|
|
}) |
|
|
|
|
Promise.all(promises).then(() => { resolve(dirPaths) }) |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
resolve(dirPaths) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
return collectList(path) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
isRemixDActive () { |
|
|
|
|
return this.appManager.isActive('remixd') |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
allPaths () { |
|
|
|
|
const dirPaths = [] |
|
|
|
|
|
|
|
|
@ -501,12 +532,12 @@ class FileManager extends Plugin { |
|
|
|
|
if (this.isDirectory(path)) { |
|
|
|
|
if (!dirPaths.includes(path)) { |
|
|
|
|
dirPaths.push(path) |
|
|
|
|
console.log('adding .. ', path) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.readdir(path).then((ls) => { |
|
|
|
|
const promises = Object.keys(ls).map((item, index) => { |
|
|
|
|
const curPath = `browser/${item}` |
|
|
|
|
const root = (path.indexOf('/') === -1) ? path : path.substr(0, path.indexOf('/')) |
|
|
|
|
const curPath = `${root}/${item}` // adding 'browser' or 'localhost'
|
|
|
|
|
if (ls[item].isDirectory) { |
|
|
|
|
return findPaths(curPath) |
|
|
|
|
} else { |
|
|
|
@ -521,9 +552,10 @@ class FileManager extends Plugin { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const br = findPaths('browser') |
|
|
|
|
const lh = findPaths('localhost') |
|
|
|
|
return Promise.all([br, lh]) |
|
|
|
|
const roots = [] |
|
|
|
|
roots.push(findPaths('browser')) |
|
|
|
|
if (this.appManager.isActive('remixd')) roots.push(findPaths('localhost')) |
|
|
|
|
return Promise.all(roots) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
saveCurrentFile () { |
|
|
|
|