08-27-周三_17-09-29
This commit is contained in:
57
node_modules/phantom/Cakefile
generated
vendored
Normal file
57
node_modules/phantom/Cakefile
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
{spawn} = require 'child_process'
|
||||
Promise = require 'bluebird'
|
||||
|
||||
bin = "./node_modules/.bin"
|
||||
sh = "/bin/sh"
|
||||
|
||||
_runCmd = (prev, current) ->
|
||||
prev.then ->
|
||||
new Promise (resolve, reject) ->
|
||||
args = ['-c', current]
|
||||
child = spawn sh, args, {stdio: 'inherit'}
|
||||
|
||||
child.on 'error', reject
|
||||
|
||||
child.on 'exit', (code) ->
|
||||
if (code or 0) is 0 then resolve() else reject()
|
||||
|
||||
run = (cmds...) ->
|
||||
seq = cmds.reduce _runCmd, Promise.resolve()
|
||||
seq.error (err) -> console.log 'Failed.', err
|
||||
|
||||
cleanup = ->
|
||||
run "rm -rf .test .shim.js"
|
||||
|
||||
exit = (code = 0) ->
|
||||
process.exit code
|
||||
|
||||
callbacks =
|
||||
success: -> console.log 'Great Success!'
|
||||
error: -> console.error 'Task failed.'
|
||||
|
||||
option '', '--test-regex [TEST_RE]', 'Run tests matching TEST_RE.'
|
||||
|
||||
task "clean", "cleanup build and test artifacts", ->
|
||||
cleanup().then -> console.log 'All clean.'
|
||||
|
||||
task "build", "coffee-compile and browserify phantom", ->
|
||||
run(
|
||||
"#{bin}/coffee -c phantom.coffee"
|
||||
"#{bin}/browserify -t coffeeify shim.coffee -o .shim.js"
|
||||
"cat pre_shim.js .shim.js > shim.js"
|
||||
)
|
||||
.then(callbacks.success, callbacks.error)
|
||||
.finally cleanup
|
||||
|
||||
task "test", "run phantom's unit tests", (options) ->
|
||||
invoke('build').then ->
|
||||
batch = run(
|
||||
"#{bin}/coffee -o .test -c test/*.coffee"
|
||||
"cp test/*.gif test/*.js .test/"
|
||||
"#{bin}/vows --spec .test/#{options['test-regex'] ? '*'}.js"
|
||||
)
|
||||
|
||||
batch
|
||||
.then(callbacks.success, callbacks.error)
|
||||
.then(cleanup)
|
||||
.catch -> exit(1)
|
Reference in New Issue
Block a user