forked from ysmood/yaku
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnofile.coffee
126 lines (107 loc) · 3.02 KB
/
nofile.coffee
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
kit = require 'nokit'
kit.require 'drives'
module.exports = (task, option) ->
task 'default build', ['doc', 'code']
task 'doc', ['code', 'utils'], 'build doc', ->
size = kit.statSync('lib/yaku.min.js').size / 1024
kit.warp 'src/*.coffee'
.load kit.drives.comment2md {
tpl: 'docs/readme.jst.md'
doc: {
size: size.toFixed 1
}
}
.run()
task 'code', 'build source code', ->
addLicense = (str) ->
{ version } = kit.require './package', __dirname
return """
/*
Yaku v#{version}
(c) 2015 Yad Smood. http://ysmood.org
License MIT
*/\n
""" + str
kit.warp 'src/yaku.coffee'
.load kit.drives.auto 'lint'
.load kit.drives.auto 'compile'
.load (f) ->
f.dest.name = 'yaku.min'
kit.outputFile 'lib/yaku.js', addLicense(f.contents)
.load kit.drives.auto 'compress'
.load (f) ->
f.set addLicense f.contents
.run 'lib'
task 'utils', 'build utils', ->
kit.warp 'src/utils.coffee'
.load kit.drives.auto 'lint'
.load kit.drives.auto 'compile'
.run 'lib'
option '--debug', 'run with remote debug server'
option '--port <8219>', 'remote debug server port', 8219
task 'lab l', 'run and monitor "test/lab.coffee"', (opts) ->
args = ['test/lab.coffee']
if opts.debug
kit.log opts.debug
args.splice 0, 0, '--nodejs', '--debug-brk=' + opts.port
kit.monitorApp { bin: 'coffee', args }
option '--grep <pattern>', 'run test that match the pattern', '.'
task 'test', 'run promise/A+ tests', (opts) ->
if opts.grep == '.'
require './test/basic'
require('./test/compliance.coffee') {
grep: opts.grep
}
option '--sync', 'sync benchmark'
task 'benchmark', ['build']
, 'compare performance between different libraries'
, (opts) ->
process.env.NODE_ENV = 'production'
os = require 'os'
console.log """
Node #{process.version}
OS #{os.platform()}
Arch #{os.arch()}
CPU #{os.cpus()[0].model}
#{kit._.repeat('-', 80)}
"""
paths = kit.globSync 'benchmark/*.coffee'
sync = if opts.sync then 'sync' else ''
kit.async paths.map (path) -> ->
kit.spawn 'coffee', [path, sync]
task 'clean', 'Clean temp files', ->
kit.remove '{.nokit,lib,.coffee,.nobone}'
option '--browserPort <8227>', 'browser test port', 8227
task 'browser', 'Unit test on browser', (opts) ->
http = require 'http'
server = http.createServer (req, res) ->
switch req.url
when '/'
kit.readFile 'test/browser.html', (html) ->
all = ''
kit.warp([
'src/yaku.coffee'
'test/basic.coffee'
])
.load kit.drives.auto 'compile'
.load (f) ->
all += f.contents + '\n\n'
f.contents = null
.run().then ->
res.end """
<html>
<body></body>
<script>#{all}</script>
</html>"""
when '/log'
req.on 'data', (c) ->
info = c.toString()
console.log info
req.on 'end', ->
res.end()
else
res.statusCode = 404
res.end()
server.listen opts.browserPort, ->
kit.log 'Listen ' + opts.browserPort
kit.xopen 'http://127.0.0.1:' + opts.browserPort