Merge pull request #44 from ethereum/changeNotifierLib

Bug Fixes
remixd
yann300 7 years ago committed by GitHub
commit c9bea2d76b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      package.json
  2. 11
      src/services/sharedFolder.js

@ -1,12 +1,12 @@
{ {
"name": "remixd", "name": "remixd",
"version": "0.1.8-alpha.3", "version": "0.1.8-alpha.4",
"description": "remix server: allow accessing file system from remix.ethereum.org and start a dev environment (see help section)", "description": "remix server: allow accessing file system from remix.ethereum.org and start a dev environment (see help section)",
"main": "./src/index.js", "main": "./src/index.js",
"bin" : { "remixd" : "./bin/remixd" }, "bin" : { "remixd" : "./bin/remixd" },
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"start": "node ./src/main.js" "start": "./bin/remixd"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

@ -46,7 +46,7 @@ module.exports = {
isbinaryfile(path, (error, isBinary) => { isbinaryfile(path, (error, isBinary) => {
if (error) console.log(error) if (error) console.log(error)
if (isBinary) { if (isBinary) {
cb(null, '<binary content not displayed>') cb(null, {content: '<binary content not displayed>', readonly: true})
} else { } else {
fs.readFile(path, 'utf8', (error, data) => { fs.readFile(path, 'utf8', (error, data) => {
if (error) console.log(error) if (error) console.log(error)
@ -64,6 +64,10 @@ module.exports = {
set: function (args, cb) { set: function (args, cb) {
var path = utils.absolutePath(args.path, this.sharedFolder) var path = utils.absolutePath(args.path, this.sharedFolder)
if (fs.existsSync(path) && !isRealPath(path, cb)) return if (fs.existsSync(path) && !isRealPath(path, cb)) return
if (args.content === 'undefined') { // no !!!!!
console.log('trying to write "undefined" ! stopping.')
return
}
this.trackDownStreamUpdate[path] = path this.trackDownStreamUpdate[path] = path
fs.writeFile(path, args.content, 'utf8', (error, data) => { fs.writeFile(path, args.content, 'utf8', (error, data) => {
if (error) console.log(error) if (error) console.log(error)
@ -99,16 +103,19 @@ module.exports = {
setupNotifications: function (path) { setupNotifications: function (path) {
if (!isRealPath(path)) return if (!isRealPath(path)) return
var watcher = chokidar.watch(path, {depth: 0, ignorePermissionErrors: true}) var watcher = chokidar.watch(path, {depth: 0, ignorePermissionErrors: true})
console.log('setup ntifications for ' + path) console.log('setup notifications for ' + path)
/* we can't listen on created file / folder
watcher.on('add', (f, stat) => { watcher.on('add', (f, stat) => {
isbinaryfile(f, (error, isBinary) => { isbinaryfile(f, (error, isBinary) => {
if (error) console.log(error) if (error) console.log(error)
console.log('add', f)
if (this.websocket.connection) this.websocket.send(message('created', { path: utils.relativePath(f, this.sharedFolder), isReadOnly: isBinary, isFolder: false })) if (this.websocket.connection) this.websocket.send(message('created', { path: utils.relativePath(f, this.sharedFolder), isReadOnly: isBinary, isFolder: false }))
}) })
}) })
watcher.on('addDir', (f, stat) => { watcher.on('addDir', (f, stat) => {
if (this.websocket.connection) this.websocket.send(message('created', { path: utils.relativePath(f, this.sharedFolder), isReadOnly: false, isFolder: true })) if (this.websocket.connection) this.websocket.send(message('created', { path: utils.relativePath(f, this.sharedFolder), isReadOnly: false, isFolder: true }))
}) })
*/
watcher.on('change', (f, curr, prev) => { watcher.on('change', (f, curr, prev) => {
if (this.trackDownStreamUpdate[f]) { if (this.trackDownStreamUpdate[f]) {
delete this.trackDownStreamUpdate[f] delete this.trackDownStreamUpdate[f]

Loading…
Cancel
Save