Skip to content
Permalink
Browse files

Add auto run on change for tests and make

  • Loading branch information
Koen Bok
Koen Bok committed Apr 25, 2013
1 parent 378e7ff commit a240ff49083bad766398570b18ac15066e177d91
Showing with 39 additions and 1 deletion.
  1. +5 −1 Makefile
  2. +34 −0 scripts/watch.coffee
@@ -7,13 +7,17 @@ build:
./node_modules/coffee-script/bin/coffee src/banner.coffee > build/framer.js
./node_modules/browserify/bin/cmd.js src/init.coffee >> build/framer.js
cp build/framer.js template/framer.js
buildw:
coffee scripts/watch.coffee . make build

test:
make
mkdir -p test/lib
cp build/framer.js test/lib/framer.js
./node_modules/browserify/bin/cmd.js test/init.coffee -o test/init.js
open test/index.html
mocha-phantomjs test/index.html
testw:
coffee scripts/watch.coffee . make test

clean:
rm -rf dist
@@ -0,0 +1,34 @@
watchr = require "watchr"
{spawn} = require "child_process"

path = process.argv[2]
cmd = process.argv[3]

child = null

console.log "Path: #{path}"
console.log "Command: #{cmd}"

watchr.watch
paths: [path]
listeners:
error: (err) ->
console.log "an error occured:", err

change: (changeType, filePath) ->

# console.log "a change event occured:", changeType, filePath
# console.log filePath.indexOf ".coffee"

if filePath.indexOf(".coffee") > -1

console.log "Running '#{cmd} #{process.argv[4..].join " "}'"

child?.kill()
child = spawn cmd, process.argv[4..]

child.stdout.on "data", (data) ->
process.stdout.write Buffer(data).toString "utf8"

child.stdout.on "error", (data) ->
process.stderr.write Buffer(data).toString "utf8"

0 comments on commit a240ff4

Please sign in to comment.
You can’t perform that action at this time.