Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 134 lines (104 sloc) 4.897 kB
88847df @jashkenas tests are now passing on symbology
authored
1 fs = require 'fs'
2 CoffeeScript = require './lib/coffee-script'
3 {spawn, exec} = require 'child_process'
34c29b3 @tim-smart Cleaner stack traces.
tim-smart authored
4 path = require 'path'
2f389f1 @jashkenas beginnings of a build script
authored
5
e4db6d4 @jashkenas Updated Cakefile from Tim_Smart with colorized, explained 'cake install'
authored
6 # ANSI Terminal Colors.
88847df @jashkenas tests are now passing on symbology
authored
7 red = '\033[0;31m'
8 green = '\033[0;32m'
9 reset = '\033[0m'
e4db6d4 @jashkenas Updated Cakefile from Tim_Smart with colorized, explained 'cake install'
authored
10
448ed36 @jashkenas got a build script for rebuilding the compiler, too
authored
11 # Run a CoffeeScript through our node/coffee interpreter.
88847df @jashkenas tests are now passing on symbology
authored
12 run = (args) ->
13 proc = spawn 'bin/coffee', args
26a115a @jashkenas Removing the mixed-in sys/util module. Switching from 'puts' to conso…
authored
14 proc.stderr.on 'data', (buffer) -> console.log buffer.toString()
d017a8f @jashkenas Moving from '.addListener' to '.on' for Node v0.1.101
authored
15 proc.on 'exit', (status) -> process.exit(1) if status != 0
2f389f1 @jashkenas beginnings of a build script
authored
16
e4db6d4 @jashkenas Updated Cakefile from Tim_Smart with colorized, explained 'cake install'
authored
17 # Log a message with a color.
88847df @jashkenas tests are now passing on symbology
authored
18 log = (message, color, explanation) ->
26a115a @jashkenas Removing the mixed-in sys/util module. Switching from 'puts' to conso…
authored
19 console.log color + message + reset + ' ' + (explanation or '')
e4db6d4 @jashkenas Updated Cakefile from Tim_Smart with colorized, explained 'cake install'
authored
20
5c7526a @jashkenas moving some of the fs methods over to sync methods, where it's alrigh…
authored
21 option '-p', '--prefix [DIR]', 'set the installation prefix for `cake install`'
17ea48c @jashkenas first draft of options for Cakefiles, using optparse.coffee, as well …
authored
22
23 task 'install', 'install CoffeeScript into /usr/local (or --prefix)', (options) ->
88847df @jashkenas tests are now passing on symbology
authored
24 base = options.prefix or '/usr/local'
9df3e6a @jashkenas first step towards requiring #{ ... } interpolation -- removing naked…
authored
25 lib = "#{base}/lib/coffee-script"
26 bin = "#{base}/bin"
88847df @jashkenas tests are now passing on symbology
authored
27 node = "~/.node_libraries/coffee-script"
26a115a @jashkenas Removing the mixed-in sys/util module. Switching from 'puts' to conso…
authored
28 console.log "Installing CoffeeScript to #{lib}"
29 console.log "Linking to #{node}"
30 console.log "Linking 'coffee' to #{bin}/coffee"
0490cb2 @jashkenas added experimental (but working) method to install CoffeeScript: 'sud…
authored
31 exec([
9df3e6a @jashkenas first step towards requiring #{ ... } interpolation -- removing naked…
authored
32 "mkdir -p #{lib} #{bin}"
33 "cp -rf bin lib LICENSE README package.json src #{lib}"
34 "ln -sf #{lib}/bin/coffee #{bin}/coffee"
35 "ln -sf #{lib}/bin/cake #{bin}/cake"
ce4e00e @jashkenas mistaken camelCase 'nodeLibraries' from the great under_score purge .…
authored
36 "mkdir -p ~/.node_libraries"
9df3e6a @jashkenas first step towards requiring #{ ... } interpolation -- removing naked…
authored
37 "ln -sf #{lib}/lib #{node}"
93f644f @jashkenas finishing the second half of prefix installs. Using readLink to refer…
authored
38 ].join(' && '), (err, stdout, stderr) ->
e4db6d4 @jashkenas Updated Cakefile from Tim_Smart with colorized, explained 'cake install'
authored
39 if err then print stderr else log 'done', green
93f644f @jashkenas finishing the second half of prefix installs. Using readLink to refer…
authored
40 )
0490cb2 @jashkenas added experimental (but working) method to install CoffeeScript: 'sud…
authored
41
42
5a81fcd @jashkenas we don't need relative require's because the paths are set up correct…
authored
43 task 'build', 'build the CoffeeScript language from source', ->
88847df @jashkenas tests are now passing on symbology
authored
44 files = fs.readdirSync 'src'
6347849 @jashkenas Switching parenthesized side in comprehensions.
authored
45 files = ('src/' + file for file in files when file.match(/\.coffee$/))
f4cd0bd @jashkenas making --run the default option for consistency. If you want to save …
authored
46 run ['-c', '-o', 'lib'].concat(files)
448ed36 @jashkenas got a build script for rebuilding the compiler, too
authored
47
bedc005 @jashkenas Adding a CoffeeScript equivalent to Rake/Make/Jake (Cake, naturally),…
authored
48
3396dce @jashkenas waypoint -- going to try to clean up regex_token
authored
49 task 'build:full', 'rebuild the source twice, and run the tests', ->
50 exec 'bin/cake build && bin/cake build && bin/cake test', (err, stdout, stderr) ->
bcf7b3f @jashkenas CoffeeScript 0.5.5, with string interpolation and internal documentation
authored
51 print stdout if stdout
52 print stderr if stderr
53 throw err if err
54
55
ff25361 @jashkenas removing the build:parser -> build dependency in the Cakefile -- the …
authored
56 task 'build:parser', 'rebuild the Jison parser (run build first)', ->
e56af49 @jashkenas removing our vendor'd copy of Jison ... you should install it from NP…
authored
57 require 'jison'
88847df @jashkenas tests are now passing on symbology
authored
58 parser = require('./lib/grammar').parser
59 js = parser.generate()
c0796da @jashkenas hacking around Jison patch to remove module dependency.
authored
60 # TODO: Remove this when the Jison patch is released.
380bee9 @satyr nagated relational operators are now grouped into NOT_RELATED, fixing…
satyr authored
61 js = js.replace 'if (require.main === module)', "if (typeof module !== 'undefined' && require.main === module)"
c0796da @jashkenas hacking around Jison patch to remove module dependency.
authored
62 fs.writeFile 'lib/parser.js', js
2f389f1 @jashkenas beginnings of a build script
authored
63
bedc005 @jashkenas Adding a CoffeeScript equivalent to Rake/Make/Jake (Cake, naturally),…
authored
64
b674163 @jashkenas adding build:ultraviolet and build:underscore tasks to the Cakefile
authored
65 task 'build:ultraviolet', 'build and install the Ultraviolet syntax highlighter', ->
7499535 @jashkenas updating the Cakefile for the new tmbundle location.
authored
66 exec 'plist2syntax ../coffee-script-tmbundle/Syntaxes/CoffeeScript.tmLanguage', (err) ->
67 throw err if err
b674163 @jashkenas adding build:ultraviolet and build:underscore tasks to the Cakefile
authored
68 exec 'sudo mv coffeescript.yaml /usr/local/lib/ruby/gems/1.8/gems/ultraviolet-0.10.2/syntax/coffeescript.syntax'
69
70
c1427d6 @jashkenas adding a minified combined coffee-script.js. Include it on the page, …
authored
71 task 'build:browser', 'rebuild the merged script for inclusion in the browser', ->
70cb195 @jashkenas rebuilding extras/coffee-script.js
authored
72 exec 'rake browser', (err) ->
73 throw err if err
c1427d6 @jashkenas adding a minified combined coffee-script.js. Include it on the page, …
authored
74
75
5b3ef78 @jashkenas adding a doc:source Cake task to document CoffeeScript's internals
authored
76 task 'doc:site', 'watch and continually rebuild the documentation for the website', ->
c1427d6 @jashkenas adding a minified combined coffee-script.js. Include it on the page, …
authored
77 exec 'rake doc'
78
79
5b3ef78 @jashkenas adding a doc:source Cake task to document CoffeeScript's internals
authored
80 task 'doc:source', 'rebuild the internal documentation', ->
202ebf0 @jashkenas documentation for command.coffee
authored
81 exec 'docco src/*.coffee && cp -rf docs documentation && rm -r docs', (err) ->
e267226 @jashkenas commenting coffee-script.coffee for documentation
authored
82 throw err if err
5b3ef78 @jashkenas adding a doc:source Cake task to document CoffeeScript's internals
authored
83
84
a3e1693 @jashkenas waypoint -- docc'd down to the SplatNode
authored
85 task 'doc:underscore', 'rebuild the Underscore.coffee documentation page', ->
25438be @jashkenas new docs for underscore
authored
86 exec 'docco examples/underscore.coffee && cp -rf docs documentation && rm -r docs', (err) ->
87 throw err if err
a3e1693 @jashkenas waypoint -- docc'd down to the SplatNode
authored
88
008d2ba @jashkenas adding a cake:bench task
authored
89 task 'bench', 'quick benchmark of compilation time (of everything in src)', ->
90 exec 'time bin/coffee -p src/ > /dev/null', (err, stdout, stderr) ->
91 print stderr
a3e1693 @jashkenas waypoint -- docc'd down to the SplatNode
authored
92
7e22568 @jashkenas making the 'cake loc' task reflect the lines of code in the compiler …
authored
93 task 'loc', 'count the lines of source code in the CoffeeScript compiler', ->
88847df @jashkenas tests are now passing on symbology
authored
94 sources = ['src/coffee-script.coffee', 'src/grammar.coffee', 'src/helpers.coffee', 'src/lexer.coffee', 'src/nodes.coffee', 'src/rewriter.coffee', 'src/scope.coffee']
89cd25a @jashkenas finished moving over string and regex interpolation to use '#' instea…
authored
95 exec "cat #{ sources.join(' ') } | grep -v '^\\( *#\\|\\s*$\\)' | wc -l | tr -s ' '", (err, stdout) ->
59e41f1 @jashkenas simpler 'cake loc' task.
authored
96 print stdout
7987d4e @jashkenas adding a cake task to check loc
authored
97
98
f360fba @sstephenson Add test:browser task for running the test suite against the merged b…
sstephenson authored
99 runTests = (CoffeeScript) ->
159150c @satyr "cake test" now wraps all of the "assert" module to update test counts
satyr authored
100 startTime = Date.now()
88847df @jashkenas tests are now passing on symbology
authored
101 passedTests = failedTests = 0
abef3f5 @satyr rebuilt parser and rewrote the asserts wrapping loop in Cakefile usin…
satyr authored
102 for all name, func of require 'assert' then do (name, func) =>
103 global[name] = -> ++passedTests; func arguments...
159150c @satyr "cake test" now wraps all of the "assert" module to update test counts
satyr authored
104 global.eq = global.strictEqual
105 global.CoffeeScript = CoffeeScript
d017a8f @jashkenas Moving from '.addListener' to '.on' for Node v0.1.101
authored
106 process.on 'exit', ->
159150c @satyr "cake test" now wraps all of the "assert" module to update test counts
satyr authored
107 time = ((Date.now() - startTime) / 1000).toFixed(2)
9df3e6a @jashkenas first step towards requiring #{ ... } interpolation -- removing naked…
authored
108 message = "passed #{passedTests} tests in #{time} seconds#{reset}"
e4db6d4 @jashkenas Updated Cakefile from Tim_Smart with colorized, explained 'cake install'
authored
109 if failedTests
9df3e6a @jashkenas first step towards requiring #{ ... } interpolation -- removing naked…
authored
110 log "failed #{failedTests} and #{message}", red
e4db6d4 @jashkenas Updated Cakefile from Tim_Smart with colorized, explained 'cake install'
authored
111 else
112 log message, green
1f2c8df @jashkenas updating to latest Node (0.1.3) API -- callbacks, not promises
authored
113 fs.readdir 'test', (err, files) ->
a27f146 @jashkenas fixing 'cake test' to print out the name of the file with the failing…
authored
114 files.forEach (file) ->
8553a89 @gfxmonk improve feedback when running the test task
gfxmonk authored
115 return unless file.match(/\.coffee$/i)
071b527 @jashkenas Issue #559, renaming {source} option to {fileName}, on CoffeeScript.c…
authored
116 fileName = path.join 'test', file
117 fs.readFile fileName, (err, code) ->
8023041 @jashkenas merging in gfxmonk's major refactor to the way that returns are pushe…
authored
118 try
071b527 @jashkenas Issue #559, renaming {source} option to {fileName}, on CoffeeScript.c…
authored
119 CoffeeScript.run code.toString(), {fileName}
8023041 @jashkenas merging in gfxmonk's major refactor to the way that returns are pushe…
authored
120 catch err
e14f4c5 @jashkenas First draft of switching the CoffeeScript Compiler over to camelCase.…
authored
121 failedTests += 1
9df3e6a @jashkenas first step towards requiring #{ ... } interpolation -- removing naked…
authored
122 log "failed #{fileName}", red, '\n' + err.stack.toString()
f360fba @sstephenson Add test:browser task for running the test suite against the merged b…
sstephenson authored
123
124
125 task 'test', 'run the CoffeeScript language test suite', ->
126 runTests CoffeeScript
127
128
129 task 'test:browser', 'run the test suite against the merged browser script', ->
130 source = fs.readFileSync 'extras/coffee-script.js', 'utf-8'
5236bb2 @sstephenson Remove the window hack in test:browser.
sstephenson authored
131 result = {}
132 (-> eval source).call result
133 runTests result.CoffeeScript
Something went wrong with that request. Please try again.