Permalink
Browse files

Add support for custom error matchers.

  • Loading branch information...
1 parent 96b0995 commit ff093732739abd949d901937489241d0a6d66d81 @epeli committed Jun 20, 2011
View
@@ -28,11 +28,29 @@ files and will start monitors defined in those.
Because shells are intended for a one output only it gets very messy if you
have several running applications on one shell. That's why Projectwatch comes
-with embedded webserver which provides a HTML based view for your task
-outputs. The view is updated instantly as your tasks are being run.
+with embedded webserver which provides a Webapp for your task viewing task
+statuses outputs. The app view is updated instantly as your tasks are being
+run. It works currently best in Chrome since it has good support for
+WebSockets.
Take a look at a screenshot [here](http://i.imgur.com/WuOad.png).
+## Error reporting
+
+Commands that exits with non zero exitstatus are considered failing.
+
+Some times tool creator has not thought through scripting use cases and we
+cannot detect whether the command succeeded. Use can provide your custom
+error checker regexp in projectwatch.cfg
+
+Example:
+
+ error.stdout = error [0-9]+
+
+Would match for "error 4" in the stdout of your command. You can similarly
+define checker for stderr.
+
+
## Usage
projectwatch [dir1[,dir2[,...]]]
@@ -47,6 +65,9 @@ projectwatch.cfg is an [ini-style][] configuration file.
watchdir = <directory to be monitored>
glob = <glob matcher for files to be monitored>
cmd = <command to be executed on changes>
+ ; Optional settings
+ error.stdout = <regexp>
+ error.stderr = <regexp>
projectwatch.cfg files can have several monitors defined in them.
@@ -91,7 +112,5 @@ GNU GENERAL PUBLIC LICENSE Version 3. See LICENCE.txt.
Todos before 1.0.0
- Use some nice command line option parser
-- Get rid off socket.io logging messages
-- Enable custom error detection
- Notify about errors using HTML5 desktop notifications
@@ -2,3 +2,4 @@
watchdir = ./scss
glob = *.scss
cmd = compass compile --css-dir css/ --sass-dir scss/
+error.stdout = error
@@ -3,5 +3,4 @@ p {
span {
color: red;
}
-
}
View
@@ -18,6 +18,12 @@ class Watcher extends EventEmitter
constructor: (@name, @cwd, @settings) ->
super
+ if @settings["error.stdout"]?
+ @stdoutError = new RegExp @settings["error.stdout"]
+
+ if @settings["error.stderr"]?
+ @stderrTest = new RegExp @settings["error.stderr"]
+
@id = @idfy @name
@settings.glob ||= "*"
@@ -80,10 +86,19 @@ class Watcher extends EventEmitter
cmd = exec @settings.cmd, cwd: @cwd, (err) =>
@running = false
+ @exitstatus = 0
+
if err
- console.log """Error in '#{ @name }'
- details http://localhost:#{ port }/##{ @id }"""
@exitstatus = err.code
+ # Fake exitstatus if user supplied testers fail
+ else if @stdoutError and @stdoutError.test @stdout
+ @exitstatus = 1
+ else if @stderrTest and @stderrTest.test @stderr
+ @exitstatus = 1
+
+ if @exitstatus isnt 0
+ console.log "Error in '#{ @name }'
+ details http://localhost:#{ port }/##{ @id }"
else
console.log "\nRan", @name, "successfully!\n", (new Date) + 2*60*60
@exitstatus = 0
@@ -42,7 +42,7 @@ class WatcherRemote extends JQEvenEmitter
remote.sendExitStatus = (exitstatus) =>
# Emits update
- console.log "Got exitstatus from server", exitstatus
+ console.log "Got exitstatus from server", exitstatus, @id
@setStatus exitstatus
View
@@ -10,7 +10,9 @@ nowjs = require("now")
app = express.createServer()
-everyone = nowjs.initialize app
+everyone = nowjs.initialize app,
+ socketio:
+ log: ->
app.set "views", __dirname + "/views"
console.log "DIR", __dirname

0 comments on commit ff09373

Please sign in to comment.