Created
October 9, 2014 11:23
-
-
Save maciejhirsz/6b9dcb41e4a5d8f8cecf to your computer and use it in GitHub Desktop.
autogrunt
This file contains hidden or 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
sys = require 'sys' | |
{exec} = require 'child_process' | |
fsevents = require 'fsevents' | |
################################### | |
compiling = false | |
compiler = null | |
notify = (message, type = 'info') -> | |
console.log(message) | |
exec "osx-notifier --title \"Grunt\" --type \"#{type}\" --message #{JSON.stringify(message)}" | |
compile = -> | |
if compiling and compiler? | |
compiler.kill("SIGKILL") | |
compiler.on 'close', (code, signal) -> compile() | |
notify("Killing previous compile", "fail") | |
return | |
compiling = true | |
start = Date.now() | |
notify('Starting Grunt') | |
compiler = exec "cd amazine; grunt scripts", (error, stdout, stderr) -> | |
message = "Done in #{Date.now() - start}ms" | |
type = "pass" | |
type = "fail" if error? | |
notify(message, type) | |
compiling = false | |
compiler.stdout.pipe process.stdout | |
watcher = fsevents('./amazine/scripts') | |
watcher.on 'change', (path) -> | |
extension = path.split('.').pop() | |
if extension in ['coffee', 'tmpl', 'scss'] | |
console.log path | |
compile() | |
watcher.start() | |
compile() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install with npm:
osx-notifier -g
fsevents
Mac only