This repository has been archived by the owner on Dec 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Cakefile
62 lines (46 loc) · 2.11 KB
/
Cakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Cakefile
fs = require "fs"
{exec} = require "child_process"
tasks = []
REPORTER = "spec"
NODE_MODULES_DIR = "./node_modules/"
TEST_BUILD_DIR = "./test/build/"
task "build", "build javascript", ->
exec "#{NODE_MODULES_DIR}.bin/coffee -c -o lib src", error
task "minify", "minfy javascript", ->
exec "#{NODE_MODULES_DIR}.bin/minify lib/youtube_iframe.js lib/youtube_iframe.min.js", error
task "open-demo", "launch the demo in a web browser", ->
exec "open demo/index.html"
task "test", "run tests on the console", ->
exec "#{NODE_MODULES_DIR}.bin/mocha-phantomjs #{TEST_BUILD_DIR}index.html", display
task "open-tests", "launch tests in a web browser", ->
exec "open #{TEST_BUILD_DIR}index.html"
task "build-tests", "compile our coffee", ->
exec "#{NODE_MODULES_DIR}.bin/coffee --compile --output #{TEST_BUILD_DIR}js/test ./test/"
exec "#{NODE_MODULES_DIR}.bin/coffee -c -o #{TEST_BUILD_DIR}js/src ./src", error
task "init-tests", "build test environment", ->
invoke("prep-tests")
invoke("copy-vendor-libs")
exec "#{NODE_MODULES_DIR}.bin/coffee build-tests.coffee #{TEST_BUILD_DIR}"
task "prep-tests", "create the test directory structure", ->
exec "mkdir .p #{TEST_BUILD_DIR}", swallow
exec "mkdir .p #{TEST_BUILD_DIR}js", swallow
exec "mkdir .p #{TEST_BUILD_DIR}js/src", swallow
exec "mkdir .p #{TEST_BUILD_DIR}js/test", swallow
exec "mkdir .p #{TEST_BUILD_DIR}js/vendor", swallow
task "copy-vendor-libs", "copy testing libs", ->
vendor = "./test/build/js/vendor/"
exec "cp #{NODE_MODULES_DIR}mocha/mocha.css #{TEST_BUILD_DIR}mocha.css", swallow
exec "cp #{NODE_MODULES_DIR}mocha/mocha.js #{vendor}mocha.js", swallow
exec "cp #{NODE_MODULES_DIR}chai/chai.js #{vendor}chai.js", swallow
exec "cp #{NODE_MODULES_DIR}sinon/pkg/sinon-1.8.2.js #{vendor}sinon.js", swallow
exec "cp #{NODE_MODULES_DIR}sinon-chai/lib/sinon-chai.js #{vendor}sinon-chai.js", swallow
task "clean-tests", "clear the test environment", ->
exec "rm -rf #{TEST_BUILD_DIR}"
display = (err, output) ->
console.log output
error = (err, output) ->
throw err if err
console.log output
swallow = (err, output) ->
return false