|
|
@ -119,39 +119,36 @@ class FileManager { |
|
|
|
return path ? path[1] : null |
|
|
|
return path ? path[1] : null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getCurrentFile (cb) { |
|
|
|
async getCurrentFile () { |
|
|
|
var path = this.currentFile() |
|
|
|
const path = this.currentFile() |
|
|
|
if (!path) { |
|
|
|
if (!path) throw 'no file selected' |
|
|
|
cb('no file selected') |
|
|
|
return path |
|
|
|
} else { |
|
|
|
|
|
|
|
cb(null, path) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getFile (path, cb) { |
|
|
|
getFile (path) { |
|
|
|
var provider = this.fileProviderOf(path) |
|
|
|
const provider = this.fileProviderOf(path) |
|
|
|
if (provider) { |
|
|
|
if (!provider) throw new Error(`${path} not available`) |
|
|
|
// TODO add approval to user for external plugin to get the content of the given `path`
|
|
|
|
// TODO: change provider to Promise
|
|
|
|
provider.get(path, (error, content) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
cb(error, content) |
|
|
|
provider.get(path, (err, content) => { |
|
|
|
|
|
|
|
if (err) reject(err) |
|
|
|
|
|
|
|
resolve(content) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
|
|
|
|
cb(path + ' not available') |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setFile (path, content, cb) { |
|
|
|
setFile (path, content) { |
|
|
|
var provider = this.fileProviderOf(path) |
|
|
|
const provider = this.fileProviderOf(path) |
|
|
|
if (provider) { |
|
|
|
if (!provider) throw new Error(`${path} not availble`) |
|
|
|
// TODO add approval to user for external plugin to set the content of the given `path`
|
|
|
|
// TODO : Add permission
|
|
|
|
|
|
|
|
// TODO : Change Provider to Promise
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
provider.set(path, content, (error) => { |
|
|
|
provider.set(path, content, (error) => { |
|
|
|
if (error) return cb(error) |
|
|
|
if (error) reject(error) |
|
|
|
this.syncEditor(path) |
|
|
|
this.syncEditor(path) |
|
|
|
cb() |
|
|
|
resolve(true) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
|
|
|
|
cb(path + ' not available') |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
removeTabsOf (provider) { |
|
|
|
removeTabsOf (provider) { |
|
|
|