4 option '-w', '--watch', '(test, compile:client) watch files for changes, and recompile results'
5 option '-W', '--wait', '(*:open) open browser and wait'
6 option '-g', '--grep [PATTERN]', '(test) see `mocha --help`'
7 option '-i', '--invert', '(test) see `mocha --help`'
8 option '-r', '--reporter [REP]', '(test) specify Mocha reporter to display test results'
9 option '-t', '--tests', '(compile:client) include tests in the bundle'
10 option '-a', '--browser [BROW]', '(*:open) select browser to use'
23 browser: 'Google Chrome' # Browser to open HTML documentation in
25 package: require './package.json'
27 open_wait_task = (opts, path) ->
28 browser = spawn 'open',
29 _.compact [ path, '-a', opts.browser ? config.docco.browser, (if opts.wait then '-W') ]
32 browser.on 'exit', -> invoke 'clean'
35 # I try to use standard `make`-target names for these tasks.
36 # See: http://www.gnu.org/software/make/manual/make.html#Standard-Targets
37 {spawn, exec} = require 'child_process'
39 task 'test', 'run testsuite through Mocha', (options) ->
40 env = Object.create process.env,
41 NODE_ENV: { value: config.mocha.env }
43 child = spawn path.resolve('./node_modules/.bin/mocha'),
44 _.compact [ '--grep', (options.grep or '.'), (if options.invert then '--invert')
45 '--watch' if options.watch
46 '--compilers', 'coffee:coffee-script'
47 '--reporter', options.reporter or config.mocha.reporter
48 '--ui', config.mocha.ui
49 path.resolve config.dirs.tests ]
51 cwd: path.resolve config.dirs.tests
53 child.on 'exit', (code) -> process.on('exit', -> process.exit code) if code > 0
55 task 'test:client', (options) ->
57 invoke 'compile:client'
58 invoke 'test:client:open'
60 task 'test:client:open', (options) ->
61 open_wait_task options, path.join(config.dirs.products, 'tests.html')
64 exec 'npm run-script coveralls', (error) ->
65 process.exit 1 if error
69 { document: docco } = require 'docco'
70 task 'docs', 'generate HTML documentation via Docco', (options) ->
71 docco [path.join config.dirs.source, '*'], { output: config.dirs.docs }, ->
72 invoke 'docs:open' if options.wait
73 task 'docs:open', (options) ->
74 open_wait_task options, path.join(config.dirs.docs, 'Paws.html')
77 #task 'compile', "write out JavaScript to lib/", -> # NYI
79 browserify = require 'browserify'
80 coffeeify = require 'coffeeify'
83 task 'compile:client', "bundle JavaScript through Browserify", (options) ->
85 #watch: options.watch # FIXME: Lost in 1.0 -> 2.0
86 #cache: true # FIXME: Lost in 1.0 -> 2.0
87 #exports: ['require', 'process'] # FIXME: Lost in 1.0 -> 2.0
88 bundle.transform coffeeify
92 bundle.add path.resolve process.cwd(), config.dirs.source, 'Paws.coffee'
94 bundle.add path.resolve process.cwd(), file for file in glob.sync config.package.testling.files
96 bundle.bundle(debug: yes).pipe fs.createWriteStream(
97 config.package.main.replace(/(?=\.(?:js|coffee))|$/, '.bundle') )
100 task 'clean', "remove git-ignore'd build products", ->
101 exec 'npm run-script clean', (error) ->
102 process.exit 1 if error
104 task 'html', -> invoke 'docs'
105 #task 'build', -> invoke 'compile'