Unverified Commit 420392a3 authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #87 from ethereum/fix_adding_removing_folder

Fix set folder / files
parents f781cffd 3a255fb7
......@@ -69,6 +69,7 @@ module.exports = {
set: function (args, cb) {
if (this.readOnly) return cb('Cannot write file: read-only mode selected')
const isFolder = args.path.endsWith('/')
var path = utils.absolutePath(args.path, this.sharedFolder)
if (fs.existsSync(path) && !isRealPath(path, cb)) return
if (args.content === 'undefined') { // no !!!!!
......@@ -76,10 +77,16 @@ module.exports = {
return
}
this.trackDownStreamUpdate[path] = path
fs.writeFile(path, args.content, 'utf8', (error, data) => {
if (error) console.log(error)
cb(error, data)
})
if (isFolder) {
fs.mkdirp(path).then(_ => cb()).catch(e => cb(e))
} else {
fs.ensureFile(path).then(() => {
fs.writeFile(path, args.content, 'utf8', (error, data) => {
if (error) console.log(error)
cb(error, data)
})
}).catch(e => cb(e))
}
},
rename: function (args, cb) {
......
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