Skip to content

Commit

Permalink
Update chokidar and add context menu items
Browse files Browse the repository at this point in the history
  • Loading branch information
piascikj committed Mar 24, 2018
1 parent 74404ea commit e570db4
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .imdone/sort.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"TODO":["108","139","104","141","109","67","93","78","87","83","98","95","72","68","69","99","94","75","80","76","71","66","81","96","296","b1da42e032be3184a88440895fcbd36033f98216","64","65","44","45","1","4","33","42","6","35","3","12","5","2","41","27","11","0","61","37282a0e7a76cc99a56b7a44ceeb5a32a70b8738","10","ac3288b84614c6cf1e5797cff1bcbd12d0853f83","66344d12347230297b6073dfe5e7e6ad667a8d53","a486a8697ce2e6e39ee0f260052f69b0bbb6111c","22","59","36","37","28","38","47","25"],"DOING":["142","141","62","59","36","10","13","44","45","20","104","139","108","107"],"BACKLOG":["34","13","21","43","46","16","23","15","9","40","31","7","19","18","26","8","30","48","39","29","37","17","45"],"NOTE":["142","92"]}
{"TODO":["144","143","108","139","104","141","109","67","93","78","87","83","98","95","72","68","69","75","99","94","80","76","71","81","66","96","296","b1da42e032be3184a88440895fcbd36033f98216","64","65","44","45","1","4","33","42","6","35","3","12","5","2","41","27","11","0","61","37282a0e7a76cc99a56b7a44ceeb5a32a70b8738","10","ac3288b84614c6cf1e5797cff1bcbd12d0853f83","66344d12347230297b6073dfe5e7e6ad667a8d53","a486a8697ce2e6e39ee0f260052f69b0bbb6111c","22","59","36","37","28","38","47","25"],"DOING":["107","75","142","141","62","59","36","10","13","44","45","20","104","139","108"],"BACKLOG":["34","13","21","43","46","16","23","15","9","40","31","7","19","18","26","8","30","48","39","29","37","17","45"],"NOTE":["142","92"]}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.4.3
- Fix issue with chokidar. Upgrade to 2.x
- Add file and directory context menus

## 2.4.2
- Wait until imdone is done saving modified files to transform tasks
- Use HTML5 notifications
Expand Down
21 changes: 19 additions & 2 deletions lib/services/worker-watched-fs-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,20 @@ function mixin(repo, fs) {
repo = fsStore(repo, fs);
repo.pause = () => repo.paused = true
repo.resume = () => delete repo.paused
repo.worker = fork(workerPath)
repo.worker = fork(workerPath, {silent: true})
repo.worker.stdout.on('data', (data) => {
log(`stdout: ${data}`);
});

repo.worker.stderr.on('data', (data) => {
log(`stderr: ${data}`);
});

repo.worker.on('close', (code) => {
log(`child process exited with code ${code}`);
});
repo.worker.on('message', ({event, data}) => {
log(`Received message from watcher for ${repo.path} event:${event}`)
if (repo.paused) return
emitter.emit(event, data)
})
Expand All @@ -38,6 +50,7 @@ function mixin(repo, fs) {

var _destroy = repo.destroy;
repo.destroy = function() {
log(`Destroying watcher for ${repo.path}`)
repo.worker.send({event: 'destroyWatcher'})
repo.reminders.destory();
_destroy.apply(repo);
Expand Down Expand Up @@ -73,6 +86,9 @@ function mixin(repo, fs) {
};

const WATCHER_EVENTS = {
log: function(data) {
log(data)
},
add: function(path) {
log("Watcher received add event for file: " + path);
var relPath = repo.getRelativePath(path);
Expand Down Expand Up @@ -118,8 +134,9 @@ function mixin(repo, fs) {
reminders: (tasks) => tasks.forEach(task => repo.reminders.notify(task))
}
repo.initWatcher = function() {
log("Creating a new watcher");
let data = {path: repo.path, exclude: repo.config.exclude, ignorePatterns: repo.ignorePatterns}
log(`Creating a new watcher with ${JSON.stringify(data)}`);

repo.worker.send({event: 'initWatcher', data})
_.keys(WATCHER_EVENTS).forEach( key => {
emitter.removeListener(key, WATCHER_EVENTS[key])
Expand Down
13 changes: 10 additions & 3 deletions lib/services/worker.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
const chokidar = require('chokidar')
const ignore = require('ignore')
const log = require('debug')('imdone-atom:worker')
let watcher
const _path = require('path')
let relative = _path.relative


process.on('message', ({event, data}) => {
send('log',{event, data})
console.log('log',{event, data})
if (event === 'refresh') return refresh()
if (event === 'initWatcher') return initWatcher(data)
if (event === 'destroyWatcher') return destroyWatcher()
})
const send = (event, data) => process.send({event, data})
const send = (event, data) => {
log('Sending event:${event} with data:${JSON.stringify(data)}')
process.send({event, data})
}
const initWatcher = function ({path, exclude, ignorePatterns}) {
console.log(`initializing watcher for ${path}`)
const ig = ignore().add(ignorePatterns)
let repoPath = path
destroyWatcher()
watcher = chokidar.watch(repoPath, {
ignored: function(path) {
console.log(`check if ${path} is ignored`)
let relPath = relative(repoPath, path)
if (relPath.indexOf('.imdone') > -1) return false
if (relPath && ig.ignores(relPath)) return true
if (!exclude) return false
console.log(`${path} is good`)
for (let i=0;i < exclude.length;i++) {
try {
let pattern = exclude[i]
let shouldExclude = (new RegExp(pattern)).test(relPath)
if (shouldExclude) return shouldExclude
} catch (e) {
send('error', e)
console.log('error', e)
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion lib/views/imdone-atom-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ class ImdoneAtomView extends ScrollView
$el.span class: opts.linkClass, "#{linkPrefix}#{opts.linkText}"
$link.dataset.filter = opts.linkPrefix.replace( "+", "\\+" )+opts.linkText
$link
# TODO: Use web components or vuejs to make the UI more testable and portable. +enhancement gh:297 id:75 ic:gh
# DOING: Use web components or vuejs to make the UI more testable and portable. +enhancement gh:297 id:75 ic:gh
# - Create a task component
# - Write task component tests
# - Use the new component in the UI
Expand Down
2 changes: 1 addition & 1 deletion menus/imdone-atom.cson
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'command': 'imdone-atom:todays-journal'
}
],
'.tree-view.full-menu': [
'.tree-view .file, .tree-view .directory': [
{
'label': 'imdone task-board'
'command': 'imdone-atom:tasks'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"dependencies": {
"async": "^1.5.2",
"atom-space-pen-views": "^2.0.5",
"chokidar": "^1.7.0",
"chokidar": "2.0.3",
"chrono-node": "^1.3.5",
"debug": "^2.2.0",
"engine.io": "^1.5.4",
Expand Down
4 changes: 4 additions & 0 deletions todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Roadmap
- #DOING: Add analytics for user actions id:107 gh:328 ic:gh
- [ ] Open board
- [ ] Create list
- [ ] add github issue
- [ ]
- #TODO: As a user I would like to clear the filter with the escape key so that I can be more productive with filtering. +story id:108 ic:gh gh:329
- #TODO: As a user I would like to save groups of visible lists so that I can have multiple process flows in a single project. id:139 gh:351 ic:gh
- #TODO: As a user I would like to add the github issue content to my TODO comment so that I can stay in the code while tracking my work. id:141 gh:354 ic:gh
Expand All @@ -24,3 +26,5 @@ Acceptance Criteria

#TODO: As a user I would like to set email reminders from TODO comments in my code +feature +imdoneio id:143 gh:361 ic:gh
#TODO: As a user I would like the label on my github issue to change if I move a task to a different list. +feature +imdoneio id:144 gh:363 ic:gh
#DOING: When creating a new project new journal file doesn't get noticed by watcher.
- [ ] Check if watcher is watching root folder

0 comments on commit e570db4

Please sign in to comment.