Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- v2.3.4 January 8, 2013 - Better handling and detection of failed watching operations - Better handling of duplicated events - Watching is now an atomic operation - If watching fails for a descendant, we will close everything related to that watch operation of the eve - We now prefer the `watch` method over the `watchFile` method - This offers great reliability and way less CPU and memory foot print - If you still wish to prefer `watchFile`, then set the new configuration option `preferredMethod` to `watchFile` - Closes [issue #30](#30) thanks to [Howard Tyson](https://github.com/tizzo)
- Loading branch information
Showing
11 changed files
with
495 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
language: node_js | ||
before_script: "make test-prepare" | ||
install: "npm install" | ||
before_script: "./node_modules/.bin/cake test-prepare" | ||
script: "./node_modules/.bin/cake test" | ||
node_js: | ||
- 0.4 | ||
- 0.6 | ||
- 0.8 | ||
- 0.9 | ||
notifications: | ||
irc: | ||
- "irc.freenode.org#bevry" | ||
- "irc.freenode.org#bevry-dev" | ||
email: | ||
recipients: | ||
- watchr@bevry.me |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# This file was originally created by Benjamin Lupton <b@lupton.cc> (http://balupton.com) | ||
# and is currently licensed under the Creative Commons Zero (http://creativecommons.org/publicdomain/zero/1.0/) | ||
# making it public domain so you can do whatever you wish with it without worry (you can even remove this notice!) | ||
# | ||
# If you change something here, be sure to reflect the changes in: | ||
# - the scripts section of the package.json file | ||
# - the .travis.yml file | ||
|
||
|
||
# ----------------- | ||
# Variables | ||
|
||
WINDOWS = process.platform.indexOf('win') is 0 | ||
NODE = process.execPath | ||
NPM = if WINDOWS then process.execPath.replace('node.exe','npm.cmd') else 'npm' | ||
EXT = (if WINDOWS then '.cmd' else '') | ||
APP = process.cwd() | ||
BIN = "#{APP}/node_modules/.bin" | ||
CAKE = "#{BIN}/cake#{EXT}" | ||
COFFEE = "#{BIN}/coffee#{EXT}" | ||
OUT = "#{APP}/out" | ||
SRC = "#{APP}/src" | ||
|
||
|
||
# ----------------- | ||
# Requires | ||
|
||
pathUtil = require('path') | ||
{exec,spawn} = require('child_process') | ||
safe = (next,fn) -> | ||
return (err) -> | ||
return next(err) if err | ||
return fn() | ||
|
||
|
||
# ----------------- | ||
# Actions | ||
|
||
clean = (opts,next) -> | ||
(next = opts; opts = {}) unless next? | ||
args = [ | ||
'-Rf' | ||
OUT | ||
pathUtil.join(APP,'node_modules') | ||
pathUtil.join(APP,'*out') | ||
pathUtil.join(APP,'*log') | ||
] | ||
spawn('rm', args, {stdio:'inherit',cwd:APP}).on('exit',next) | ||
|
||
compile = (opts,next) -> | ||
(next = opts; opts = {}) unless next? | ||
spawn(COFFEE, ['-co', OUT, SRC], {stdio:'inherit',cwd:APP}).on('exit',next) | ||
|
||
example = (opts,next) -> | ||
(next = opts; opts = {}) unless next? | ||
compile opts, safe next, -> | ||
command = pathUtil.resolve("#{__dirname}/bin/watchr") | ||
spawn(command, [], {stdio:'inherit',cwd:APP,env:process.env}).on('exit',next) | ||
|
||
watch = (opts,next) -> | ||
(next = opts; opts = {}) unless next? | ||
spawn(COFFEE, ['-wco', OUT, SRC], {stdio:'inherit',cwd:APP}).on('exit',next) | ||
|
||
install = (opts,next) -> | ||
(next = opts; opts = {}) unless next? | ||
spawn(NPM, ['install'], {stdio:'inherit',cwd:APP}).on('exit',next) | ||
|
||
reset = (opts,next) -> | ||
(next = opts; opts = {}) unless next? | ||
clean opts, safe next, -> | ||
install opts, safe next, -> | ||
compile opts, next | ||
|
||
setup = (opts,next) -> | ||
(next = opts; opts = {}) unless next? | ||
install opts, safe next, -> | ||
compile opts, next | ||
|
||
test = (opts,next) -> | ||
(next = opts; opts = {}) unless next? | ||
spawn(NPM, ['test'], {stdio:'inherit',cwd:APP}).on('exit',next) | ||
|
||
finish = (err) -> | ||
throw err if err | ||
console.log('OK') | ||
|
||
|
||
# ----------------- | ||
# Commands | ||
|
||
# clean | ||
task 'clean', 'clean up instance', -> | ||
clean finish | ||
|
||
# compile | ||
task 'compile', 'compile our files', -> | ||
compile finish | ||
|
||
# dev/watch | ||
task 'dev', 'watch and recompile our files', -> | ||
watch finish | ||
task 'watch', 'watch and recompile our files', -> | ||
watch finish | ||
|
||
# example | ||
task 'example', 'run the example file', -> | ||
example finish | ||
|
||
# install | ||
task 'install', 'install dependencies', -> | ||
install finish | ||
|
||
# reset | ||
task 'reset', 'reset instance', -> | ||
reset finish | ||
|
||
# setup | ||
task 'setup', 'setup for development', -> | ||
setup finish | ||
|
||
# test | ||
task 'test', 'run our tests', -> | ||
test finish | ||
|
||
# test-debug | ||
task 'test-debug', 'run our tests in debug mode', -> | ||
test {debug:true}, finish | ||
|
||
# test-prepare | ||
task 'test-prepare', 'prepare out tests', -> | ||
setup finish | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,43 @@ | ||
#!/usr/bin/env node | ||
require(__dirname+'/../out/bin/watchr'); | ||
// Require | ||
var watchr = require(__dirname+'/../out/lib/watchr'); | ||
|
||
// Watch a directory or file | ||
console.log('Watch our paths'); | ||
watchr.watch({ | ||
paths: [process.cwd()], | ||
listeners: { | ||
log: function(logLevel){ | ||
console.log('a log message occured:', arguments); | ||
}, | ||
error: function(err){ | ||
console.log('an error occured:', err); | ||
}, | ||
watching: function(err,watcherInstance,isWatching){ | ||
if (err) { | ||
console.log("watching the path " + watcherInstance.path + " failed with error", err); | ||
} else { | ||
console.log("watching the path " + watcherInstance.path + " completed"); | ||
} | ||
}, | ||
change: function(changeType,filePath,fileCurrentStat,filePreviousStat){ | ||
console.log('a change event occured:',arguments); | ||
} | ||
}, | ||
next: function(err,watchers){ | ||
if (err) { | ||
return console.log("watching everything failed with error", err); | ||
} else { | ||
console.log('watching everything completed', watchers); | ||
} | ||
|
||
// Close watchers after 10 seconds | ||
setTimeout(function(){ | ||
var i; | ||
console.log('Stop watching our paths'); | ||
for ( i=0; i<watchers.length; i++ ) { | ||
watchers[i].close(); | ||
} | ||
},10*1000); | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.