Skip to content

Instantly share code, notes, and snippets.

@craftgear
Created February 23, 2012 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craftgear/1895416 to your computer and use it in GitHub Desktop.
Save craftgear/1895416 to your computer and use it in GitHub Desktop.
jade watch
# run with 'coffee jadewatch.coffee dirname'
fs = require 'fs'
if process.argv.length < 3
console.log 'Aborted: arguments are too short.'
return
else
child_process = require('child_process')
child_process.exec "ps", (err,stdout,stderr)->
if stdout.indexOf("coffee jadewatch.coffee") < 0
console.log "jade is watching " + process.argv[2]
fs.watchFile process.argv[2], {persistent:true, interval:500}, (curr, prev)->
return if curr.size == prev.size && curr.mtime.getTime() == prev.mtime.getTime()
child_process.exec("jade " + process.argv[2], (err, stdout, stderr)->
console.log stdout
console.log stderr
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment