Skip to content

Commit

Permalink
Add auto run on change for tests and make
Browse files Browse the repository at this point in the history
  • Loading branch information
Koen Bok committed Apr 25, 2013
1 parent 378e7ff commit a240ff4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ build:
./node_modules/coffee-script/bin/coffee src/banner.coffee > build/framer.js ./node_modules/coffee-script/bin/coffee src/banner.coffee > build/framer.js
./node_modules/browserify/bin/cmd.js src/init.coffee >> build/framer.js ./node_modules/browserify/bin/cmd.js src/init.coffee >> build/framer.js
cp build/framer.js template/framer.js cp build/framer.js template/framer.js
buildw:
coffee scripts/watch.coffee . make build


test: test:
make make
mkdir -p test/lib mkdir -p test/lib
cp build/framer.js test/lib/framer.js cp build/framer.js test/lib/framer.js
./node_modules/browserify/bin/cmd.js test/init.coffee -o test/init.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: clean:
rm -rf dist rm -rf dist
Expand Down
34 changes: 34 additions & 0 deletions scripts/watch.coffee
Original file line number Original file line Diff line number Diff line change
@@ -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.