Created
November 20, 2012 12:31
-
-
Save DimitarChristoff/4117652 to your computer and use it in GitHub Desktop.
watch example
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
test := cloudpipes-site/src/test | |
source := cloudpipes-site/src/main | |
target := cloudpipes-site/target/cloudpipes-site-1.0-SNAPSHOT/static | |
targettpl := cloudpipes-site/target/cloudpipes-site-1.0-SNAPSHOT/resources/templates/ | |
install: | |
npm link . | |
@command -v casperjs >/dev/null 2>&1 || { echo 'Missing casperjs'; brew install casperjs; } | |
less: | |
@recess $(source)/less/cloudpipes-main.less --compile > $(target)/css/cloudpipes-main.css ; if [ $$? -eq 0 ] ; then \ | |
growlnotify -t "LESS" -m "CSS built via recess" ; \ | |
else growlnotify -t "LESS FAILED" -m "CSS did not build via recess" ; \ | |
fi | |
rsync: | |
rsync -avz $(source)/webapp/static/ $(target) ; \ | |
growlnotify -t "Rsync to target" -m "Watchr found changes and moved from src to target" ; \ | |
rsynctpl: | |
rsync -avz $(source)/webapp/resources/templates/ $(targettpl) ; \ | |
growlnotify -t "Rsync TEMPLATES to target" -m "Watchr found changes and moved from src to target" ; \ | |
watch: | |
node watch.js | |
test: | |
@casperjs test $(test)/js/ ; if [ $$? -eq 0 ] ; then \ | |
growlnotify -t "[casperjs]" -m "integration tests passed" ; \ | |
else growlnotify -t "[FAIL][casperjs]" -m "Tests did not pass" ; \ | |
fi |
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
#!/usr/bin/env node | |
// recompile main minified file when sources change | |
var watch = require('watch'), | |
ps = require('child_process'), | |
source = 'cloudpipes-site/src/main', | |
// now configs for two watches | |
watchr = [{ | |
source: source + '/less/', | |
run: 'make less' | |
}, { | |
source: source + '/webapp/static/', | |
run: 'make rsync' | |
}, { | |
source: source + '/webapp/resources/templates', | |
run: 'make rsynctpl' | |
}]; | |
watchr.forEach(function(obj) { | |
console.log('watching ' + obj.source); | |
watch.createMonitor(obj.source, function(monitor) { | |
var run = function(){ | |
ps.exec(obj.run, function(error, stdout) { | |
if (!error) { | |
console.log(stdout); | |
} | |
else { | |
console.log('fucksocks'); | |
} | |
console.log(''); | |
}); | |
}; | |
monitor.on('created', run); | |
monitor.on('removed', run); | |
monitor.on('changed', run); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment