Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 121 lines (95 sloc) 4.225 kb
88847df @jashkenas tests are now passing on symbology
authored
1 fs = require 'fs'
2 {helpers} = require './lib/helpers'
3 CoffeeScript = require './lib/coffee-script'
4 {spawn, exec} = require 'child_process'
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
d017a8f @jashkenas Moving from '.addListener' to '.on' for Node v0.1.101
authored
14 proc.stderr.on 'data', (buffer) -> puts buffer.toString()
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) ->
89cd25a @jashkenas finished moving over string and regex interpolation to use '#' instead o...
authored
19 puts "#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 alright a...
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 as ...
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'
89cd25a @jashkenas finished moving over string and regex interpolation to use '#' instead o...
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"
89cd25a @jashkenas finished moving over string and regex interpolation to use '#' instead o...
authored
28 puts "Installing CoffeeScript to #lib"
29 puts "Linking to #node"
30 puts "Linking 'coffee' to #bin/coffee"
0490cb2 @jashkenas added experimental (but working) method to install CoffeeScript: 'sudo b...
authored
31 exec([
89cd25a @jashkenas finished moving over string and regex interpolation to use '#' instead o...
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"
89cd25a @jashkenas finished moving over string and regex interpolation to use '#' instead o...
authored
37 "ln -sf #lib/lib #node"
93f644f @jashkenas finishing the second half of prefix installs. Using readLink to refer to...
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 to...
authored
40 )
0490cb2 @jashkenas added experimental (but working) method to install CoffeeScript: 'sudo b...
authored
41
42
5a81fcd @jashkenas we don't need relative require's because the paths are set up correctly ...
authored
43 task 'build', 'build the CoffeeScript language from source', ->
88847df @jashkenas tests are now passing on symbology
authored
44 files = fs.readdirSync 'src'
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 the...
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), an...
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 asy...
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 NPM n...
authored
57 require 'jison'
88847df @jashkenas tests are now passing on symbology
authored
58 parser = require('./lib/grammar').parser
59 js = parser.generate()
60 parserPath = 'lib/parser.js'
e14f4c5 @jashkenas First draft of switching the CoffeeScript Compiler over to camelCase. Po...
authored
61 fs.writeFile parserPath, js
2f389f1 @jashkenas beginnings of a build script
authored
62
bedc005 @jashkenas Adding a CoffeeScript equivalent to Rake/Make/Jake (Cake, naturally), an...
authored
63
b674163 @jashkenas adding build:ultraviolet and build:underscore tasks to the Cakefile
authored
64 task 'build:ultraviolet', 'build and install the Ultraviolet syntax highlighter', ->
7499535 @jashkenas updating the Cakefile for the new tmbundle location.
authored
65 exec 'plist2syntax ../coffee-script-tmbundle/Syntaxes/CoffeeScript.tmLanguage', (err) ->
66 throw err if err
b674163 @jashkenas adding build:ultraviolet and build:underscore tasks to the Cakefile
authored
67 exec 'sudo mv coffeescript.yaml /usr/local/lib/ruby/gems/1.8/gems/ultraviolet-0.10.2/syntax/coffeescript.syntax'
68
69
c1427d6 @jashkenas adding a minified combined coffee-script.js. Include it on the page, aft...
authored
70 task 'build:browser', 'rebuild the merged script for inclusion in the browser', ->
70cb195 @jashkenas rebuilding extras/coffee-script.js
authored
71 exec 'rake browser', (err) ->
72 throw err if err
c1427d6 @jashkenas adding a minified combined coffee-script.js. Include it on the page, aft...
authored
73
74
5b3ef78 @jashkenas adding a doc:source Cake task to document CoffeeScript's internals
authored
75 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, aft...
authored
76 exec 'rake doc'
77
78
5b3ef78 @jashkenas adding a doc:source Cake task to document CoffeeScript's internals
authored
79 task 'doc:source', 'rebuild the internal documentation', ->
202ebf0 @jashkenas documentation for command.coffee
authored
80 exec 'docco src/*.coffee && cp -rf docs documentation && rm -r docs', (err) ->
e267226 @jashkenas commenting coffee-script.coffee for documentation
authored
81 throw err if err
5b3ef78 @jashkenas adding a doc:source Cake task to document CoffeeScript's internals
authored
82
83
a3e1693 @jashkenas waypoint -- docc'd down to the SplatNode
authored
84 task 'doc:underscore', 'rebuild the Underscore.coffee documentation page', ->
25438be @jashkenas new docs for underscore
authored
85 exec 'docco examples/underscore.coffee && cp -rf docs documentation && rm -r docs', (err) ->
86 throw err if err
a3e1693 @jashkenas waypoint -- docc'd down to the SplatNode
authored
87
88
7e22568 @jashkenas making the 'cake loc' task reflect the lines of code in the compiler onl...
authored
89 task 'loc', 'count the lines of source code in the CoffeeScript compiler', ->
88847df @jashkenas tests are now passing on symbology
authored
90 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 '#' instead o...
authored
91 exec "cat #{ sources.join(' ') } | grep -v '^\\( *#\\|\\s*$\\)' | wc -l | tr -s ' '", (err, stdout) ->
59e41f1 @jashkenas simpler 'cake loc' task.
authored
92 print stdout
7987d4e @jashkenas adding a cake task to check loc
authored
93
94
bedc005 @jashkenas Adding a CoffeeScript equivalent to Rake/Make/Jake (Cake, naturally), an...
authored
95 task 'test', 'run the CoffeeScript language test suite', ->
02f4cb7 @jashkenas removing deprecated references to process.mixin in favor of helpers.exte...
authored
96 helpers.extend global, require 'assert'
88847df @jashkenas tests are now passing on symbology
authored
97 passedTests = failedTests = 0
98 startTime = new Date
99 originalOk = ok
02f4cb7 @jashkenas removing deprecated references to process.mixin in favor of helpers.exte...
authored
100 helpers.extend global, {
e14f4c5 @jashkenas First draft of switching the CoffeeScript Compiler over to camelCase. Po...
authored
101 ok: (args...) -> passedTests += 1; originalOk(args...)
1b4edd0 @jashkenas scrubbing all carriage returns from CoffeeScript source before compiling...
authored
102 CoffeeScript: CoffeeScript
bedc005 @jashkenas Adding a CoffeeScript equivalent to Rake/Make/Jake (Cake, naturally), an...
authored
103 }
d017a8f @jashkenas Moving from '.addListener' to '.on' for Node v0.1.101
authored
104 process.on 'exit', ->
88847df @jashkenas tests are now passing on symbology
authored
105 time = ((new Date - startTime) / 1000).toFixed(2)
89cd25a @jashkenas finished moving over string and regex interpolation to use '#' instead o...
authored
106 message = "passed #passedTests tests in #time seconds#reset"
e4db6d4 @jashkenas Updated Cakefile from Tim_Smart with colorized, explained 'cake install'
authored
107 if failedTests
89cd25a @jashkenas finished moving over string and regex interpolation to use '#' instead o...
authored
108 log "failed #failedTests and #message", red
e4db6d4 @jashkenas Updated Cakefile from Tim_Smart with colorized, explained 'cake install'
authored
109 else
110 log message, green
1f2c8df @jashkenas updating to latest Node (0.1.3) API -- callbacks, not promises
authored
111 fs.readdir 'test', (err, files) ->
a27f146 @jashkenas fixing 'cake test' to print out the name of the file with the failing te...
authored
112 files.forEach (file) ->
8553a89 @gfxmonk improve feedback when running the test task
gfxmonk authored
113 return unless file.match(/\.coffee$/i)
88847df @jashkenas tests are now passing on symbology
authored
114 source = path.join 'test', file
8023041 @jashkenas merging in gfxmonk's major refactor to the way that returns are pushed d...
authored
115 fs.readFile source, (err, code) ->
116 try
a8d4c3a @jashkenas sprinkling toString() throughout, for Node.js 0.1.95 compatibility.
authored
117 CoffeeScript.run code.toString(), {source: source}
8023041 @jashkenas merging in gfxmonk's major refactor to the way that returns are pushed d...
authored
118 catch err
e14f4c5 @jashkenas First draft of switching the CoffeeScript Compiler over to camelCase. Po...
authored
119 failedTests += 1
89cd25a @jashkenas finished moving over string and regex interpolation to use '#' instead o...
authored
120 log "failed #source", red, '\n' + err.stack.toString()
Something went wrong with that request. Please try again.