Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.12.4 #4441

Merged
merged 12 commits into from
Feb 18, 2017
Merged

1.12.4 #4441

Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 121 additions & 59 deletions Cakefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,65 +24,31 @@ header = """
*/
"""

# Used in folder names like docs/v1
# Used in folder names like `docs/v1`.
majorVersion = parseInt CoffeeScript.VERSION.split('.')[0], 10

# Build the CoffeeScript language from source.
build = (cb) ->
files = fs.readdirSync 'src'
files = ('src/' + file for file in files when file.match(/\.(lit)?coffee$/))
run ['-c', '-o', 'lib/coffee-script'].concat(files), cb

# Run a CoffeeScript through our node/coffee interpreter.
run = (args, cb) ->
proc = spawn 'node', ['bin/coffee'].concat(args)
proc.stderr.on 'data', (buffer) -> console.log buffer.toString()
proc.on 'exit', (status) ->
process.exit(1) if status isnt 0
cb() if typeof cb is 'function'

# Log a message with a color.
log = (message, color, explanation) ->
console.log color + message + reset + ' ' + (explanation or '')

option '-p', '--prefix [DIR]', 'set the installation prefix for `cake install`'

task 'install', 'install CoffeeScript into /usr/local (or --prefix)', (options) ->
base = options.prefix or '/usr/local'
lib = "#{base}/lib/coffee-script"
bin = "#{base}/bin"
node = "~/.node_libraries/coffee-script"
console.log "Installing CoffeeScript to #{lib}"
console.log "Linking to #{node}"
console.log "Linking 'coffee' to #{bin}/coffee"
exec([
"mkdir -p #{lib} #{bin}"
"cp -rf bin lib LICENSE README.md package.json src #{lib}"
"ln -sfn #{lib}/bin/coffee #{bin}/coffee"
"ln -sfn #{lib}/bin/cake #{bin}/cake"
"mkdir -p ~/.node_libraries"
"ln -sfn #{lib}/lib/coffee-script #{node}"
].join(' && '), (err, stdout, stderr) ->
if err then console.log stderr.trim() else log 'done', green
)


task 'build', 'build the CoffeeScript language from source', build

task 'build:full', 'rebuild the source twice, and run the tests', ->
build ->
build ->
csPath = './lib/coffee-script'
csDir = path.dirname require.resolve csPath

for mod of require.cache when csDir is mod[0 ... csDir.length]
delete require.cache[mod]
spawnNodeProcess = (args, output = 'stderr', callback) ->
relayOutput = (buffer) -> console.log buffer.toString()
proc = spawn 'node', args
proc.stdout.on 'data', relayOutput if output is 'both' or output is 'stdout'
proc.stderr.on 'data', relayOutput if output is 'both' or output is 'stderr'
proc.on 'exit', (status) -> callback(status) if typeof callback is 'function'

unless runTests require csPath
process.exit 1
# Run a CoffeeScript through our node/coffee interpreter.
run = (args, callback) ->
spawnNodeProcess ['bin/coffee'].concat(args), 'stderr', (status) ->
process.exit(1) if status isnt 0
callback() if typeof callback is 'function'


task 'build:parser', 'rebuild the Jison parser (run build first)', ->
# Build the CoffeeScript language from source.
buildParser = ->
helpers.extend global, require 'util'
require 'jison'
parser = require('./lib/coffee-script/grammar').parser.generate()
Expand All @@ -95,8 +61,65 @@ task 'build:parser', 'rebuild the Jison parser (run build first)', ->
source = fs"""
fs.writeFileSync 'lib/coffee-script/parser.js', parser

buildExceptParser = (callback) ->
files = fs.readdirSync 'src'
files = ('src/' + file for file in files when file.match(/\.(lit)?coffee$/))
run ['-c', '-o', 'lib/coffee-script'].concat(files), callback

build = (callback) ->
buildParser()
buildExceptParser callback

testBuiltCode = (watch = no) ->
csPath = './lib/coffee-script'
csDir = path.dirname require.resolve csPath

for mod of require.cache when csDir is mod[0 ... csDir.length]
delete require.cache[mod]

testResults = runTests require csPath
unless watch
process.exit 1 unless testResults

buildAndTest = (includingParser = yes, harmony = no) ->
process.stdout.write '\x1Bc' # Clear terminal screen.
execSync 'git checkout lib/*', stdio: [0,1,2] # Reset the generated compiler.

buildArgs = ['bin/cake']
buildArgs.push if includingParser then 'build' else 'build:except-parser'
log "building#{if includingParser then ', including parser' else ''}...", green
spawnNodeProcess buildArgs, 'both', ->
log 'testing...', green
testArgs = if harmony then ['--harmony'] else []
testArgs = testArgs.concat ['bin/cake', 'test']
spawnNodeProcess testArgs, 'both'

watchAndBuildAndTest = (harmony = no) ->
buildAndTest yes, harmony
fs.watch 'src/', interval: 200, (eventType, filename) ->
if eventType is 'change'
log "src/#{filename} changed, rebuilding..."
buildAndTest (filename is 'grammar.coffee'), harmony
fs.watch 'test/',
interval: 200
recursive: yes
, (eventType, filename) ->
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naked leading comma is poor CoffeeScript style — wrap the object in braces.

if eventType is 'change'
log "test/#{filename} changed, rebuilding..."
buildAndTest no, harmony


task 'build', 'build the CoffeeScript compiler from source', build

task 'build:parser', 'build the Jison parser only', buildParser

task 'build:except-parser', 'build the CoffeeScript compiler, except for the Jison parser', buildExceptParser

task 'build:full', 'build the CoffeeScript compiler from source twice, and run the tests', ->
build ->
build testBuiltCode

task 'build:browser', 'rebuild the merged script for inclusion in the browser', ->
task 'build:browser', 'build the merged script for inclusion in the browser', ->
code = """
require['../../package.json'] = (function() {
return #{fs.readFileSync "./package.json"};
Expand Down Expand Up @@ -137,8 +160,14 @@ task 'build:browser', 'rebuild the merged script for inclusion in the browser',
console.log "built ... running browser tests:"
invoke 'test:browser'

task 'build:watch', 'watch and continually rebuild the CoffeeScript compiler, running tests on each build', ->
watchAndBuildAndTest()

task 'build:watch:harmony', 'watch and continually rebuild the CoffeeScript compiler, running harmony tests on each build', ->
watchAndBuildAndTest yes


task 'doc:site', 'watch and continually rebuild the documentation for the website', ->
buildDocs = (watch = no) ->
# Constants
indexFile = 'documentation/index.html'
versionedSourceFolder = "documentation/v#{majorVersion}"
Expand Down Expand Up @@ -211,12 +240,19 @@ task 'doc:site', 'watch and continually rebuild the documentation for the websit
fs.symlinkSync "v#{majorVersion}/index.html", 'docs/index.html'
catch exception

for target in [indexFile, versionedSourceFolder, examplesSourceFolder, sectionsSourceFolder]
fs.watch target, interval: 200, renderIndex
log 'watching...' , green
if watch
for target in [indexFile, versionedSourceFolder, examplesSourceFolder, sectionsSourceFolder]
fs.watch target, interval: 200, renderIndex
log 'watching...', green

task 'doc:site', 'build the documentation for the website', ->
buildDocs()

task 'doc:test', 'watch and continually rebuild the browser-based tests', ->
task 'doc:site:watch', 'watch and continually rebuild the documentation for the website', ->
buildDocs yes


buildDocTests = (watch = no) ->
# Constants
testFile = 'documentation/test.html'
testsSourceFolder = 'test'
Expand Down Expand Up @@ -254,14 +290,40 @@ task 'doc:test', 'watch and continually rebuild the browser-based tests', ->
fs.writeFileSync "#{outputFolder}/test.html", output
log 'compiled', green, "#{testFile} → #{outputFolder}/test.html"

for target in [testFile, testsSourceFolder]
fs.watch target, interval: 200, renderTest
log 'watching...' , green
if watch
for target in [testFile, testsSourceFolder]
fs.watch target, interval: 200, renderTest
log 'watching...', green

task 'doc:test', 'build the browser-based tests', ->
buildDocTests()

task 'doc:test:watch', 'watch and continually rebuild the browser-based tests', ->
buildDocTests yes


buildAnnotatedSource = (watch = no) ->
do generateAnnotatedSource = ->
exec "node_modules/docco/bin/docco src/*.*coffee --output docs/v#{majorVersion}/annotated-source", (err) -> throw err if err
log 'generated', green, "annotated source in docs/v#{majorVersion}/annotated-source/"

if watch
fs.watch 'src/', interval: 200, generateAnnotatedSource
log 'watching...', green

task 'doc:source', 'build the annotated source documentation', ->
buildAnnotatedSource()

task 'doc:source:watch', 'watch and continually rebuild the annotated source documentation', ->
buildAnnotatedSource yes

task 'doc:source', 'rebuild the annotated source documentation', ->
exec "node_modules/docco/bin/docco src/*.*coffee --output docs/v#{majorVersion}/annotated-source", (err) -> throw err if err

task 'release', 'build and test the CoffeeScript source, and build the documentation', ->
invoke 'build:full'
invoke 'build:browser'
invoke 'doc:site'
invoke 'doc:test'
invoke 'doc:source'

task 'bench', 'quick benchmark of compilation time', ->
{Rewriter} = require './lib/coffee-script/rewriter'
Expand Down
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,10 @@ CoffeeScript is a little language that compiles into JavaScript.
If you have the node package manager, npm, installed:

```shell
npm install -g coffee-script
npm install --global coffee-script
```

Leave off the `-g` if you don't wish to install globally. If you don't wish to use npm:

```shell
git clone https://github.com/jashkenas/coffeescript.git
sudo coffeescript/bin/cake install
```
Leave off the `--global` if you don’t wish to install globally.

## Getting Started

Expand All @@ -53,7 +48,7 @@ For documentation, usage, and examples, see: http://coffeescript.org/

To suggest a feature or report a bug: http://github.com/jashkenas/coffeescript/issues

If you'd like to chat, drop by #coffeescript on Freenode IRC.
If youd like to chat, drop by #coffeescript on Freenode IRC.

The source repository: https://github.com/jashkenas/coffeescript.git

Expand Down
4 changes: 2 additions & 2 deletions docs/v1/browser-compiler/coffee-script.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 14 additions & 5 deletions docs/v1/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@
<p><strong>CoffeeScript is a little language that compiles into JavaScript.</strong> Underneath that awkward Java-esque patina, JavaScript has always had a gorgeous heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.</p>
<p>The golden rule of CoffeeScript is: <em>“It’s just JavaScript”</em>. The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime. You can use any existing JavaScript library seamlessly from CoffeeScript (and vice-versa). The compiled output is readable, pretty-printed, and tends to run as fast or faster than the equivalent handwritten JavaScript.</p>
<p>The CoffeeScript compiler goes to great lengths to generate output JavaScript that runs in every JavaScript runtime, but there are exceptions. Use <a href="#generator-functions">generator functions</a>, <a href="#generator-iteration"><code>for…from</code></a>, or <a href="#tagged-template-literals">tagged template literals</a> only if you know that your <a href="http://kangax.github.io/compat-table/es6/">target runtimes can support them</a>. If you use <a href="#modules">modules</a>, you will need to <a href="#modules-note">use an additional tool to resolve them</a>.</p>
<p><strong>Latest Version:</strong> <a href="http://github.com/jashkenas/coffeescript/tarball/1.12.3">1.12.3</a></p>
<p><strong>Latest Version:</strong> <a href="http://github.com/jashkenas/coffeescript/tarball/1.12.4">1.12.4</a></p>
<blockquote>
<pre><code>npm install -g coffee-script</code></pre></blockquote>

Expand Down Expand Up @@ -2584,9 +2584,9 @@ <h2>Resources</h2><ul>
<li><p><a href="http://github.com/jashkenas/coffeescript/">Source Code</a><br>
Use <code>bin/coffee</code> to test your changes,<br>
<code>bin/cake test</code> to run the test suite,<br>
<code>bin/cake build</code> to rebuild the CoffeeScript compiler, and<br>
<code>bin/cake build:parser</code> to regenerate the Jison parser if you’re working on the grammar.</p>
<p><code>git checkout lib &amp;&amp; bin/cake build:full</code> is a good command to run when you’re working on the core language. It’ll refresh the lib directory (in case you broke something), build your altered compiler, use that to rebuild itself (a good sanity test) and then run all of the tests. If they pass, there’s a good chance you’ve made a successful change.</p>
<code>bin/cake build</code> to rebuild the full CoffeeScript compiler, and<br>
<code>bin/cake build:except-parser</code> to recompile much faster if you’re not editing <code>grammar.coffee</code>.</p>
<p><code>git checkout lib &amp;&amp; bin/cake build:full</code> is a good command to run when you’re working on the core language. It’ll refresh the <code>lib</code> folder (in case you broke something), build your altered compiler, use that to rebuild itself (a good sanity test) and then run all of the tests. If they pass, there’s a good chance you’ve made a successful change.</p>
</li>
<li><a href="v1/test.html">Browser Tests</a><br>
Run CoffeeScript’s test suite in your current browser.</li>
Expand All @@ -2609,7 +2609,16 @@ <h2>Web Chat (IRC)</h2><p>Quick help and advice can usually be found in the Coff
<button id="open_webchat">click to open #coffeescript</button>

<span class="bookmark" id="changelog"></span>
<h2>Change Log</h2><div class="anchor" id="1.12.3"></div>
<h2>Change Log</h2><div class="anchor" id="1.12.4"></div>
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.12.3...1.12.4">1.12.4</a>
<span class="timestamp"> &mdash; <time datetime="2017-02-15">February 15, 2017</time></span>
</h2><ul>
<li>The <code>cake</code> commands have been updated, with new <code>watch</code> options for most tasks. Clone the <a href="https://github.com/jashkenas/coffeescript">CoffeeScript repo</a> and run <code>cake</code> at the root of the repo to see the options.</li>
<li>Fixed a bug where <code>export</code>ing a referenced variable was preventing the variable from being declared.</li>
<li>Fixed a bug where the <code>coffee</code> command wasn’t working for a <code>.litcoffee</code> file.</li>
</ul>
<div class="anchor" id="1.12.3"></div>
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.12.2...1.12.3">1.12.3</a>
<span class="timestamp"> &mdash; <time datetime="2017-01-24">January 24, 2017</time></span>
Expand Down
8 changes: 8 additions & 0 deletions documentation/sections/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## Change Log

```
releaseHeader('2017-02-15', '1.12.4', '1.12.3')
```

* The `cake` commands have been updated, with new `watch` options for most tasks. Clone the [CoffeeScript repo](https://github.com/jashkenas/coffeescript) and run `cake` at the root of the repo to see the options.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As someone who has worked on the CoffeeScript source code, this is easily the most exciting part of the changelog. But do "regular users" even care? I'm not sure that we should mention the changes to CoffeeScript's internal Cakefile here – might just be confusing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I thought it was worth mentioning because the docs mentioned the cake commands, though I've been removing those references. They're still mentioned all over the place in the wiki etc.

* Fixed a bug where `export`ing a referenced variable was preventing the variable from being declared.
* Fixed a bug where the `coffee` command wasn’t working for a `.litcoffee` file.

```
releaseHeader('2017-01-24', '1.12.3', '1.12.2')
```
Expand Down
6 changes: 3 additions & 3 deletions documentation/sections/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* [Source Code](http://github.com/jashkenas/coffeescript/)<br>
Use `bin/coffee` to test your changes,<br>
`bin/cake test` to run the test suite,<br>
`bin/cake build` to rebuild the CoffeeScript compiler, and<br>
`bin/cake build:parser` to regenerate the Jison parser if you’re working on the grammar.
`bin/cake build` to rebuild the full CoffeeScript compiler, and<br>
`bin/cake build:except-parser` to recompile much faster if you’re not editing `grammar.coffee`.

`git checkout lib && bin/cake build:full` is a good command to run when you’re working on the core language. It’ll refresh the lib directory (in case you broke something), build your altered compiler, use that to rebuild itself (a good sanity test) and then run all of the tests. If they pass, there’s a good chance you’ve made a successful change.
`git checkout lib && bin/cake build:full` is a good command to run when you’re working on the core language. It’ll refresh the `lib` folder (in case you broke something), build your altered compiler, use that to rebuild itself (a good sanity test) and then run all of the tests. If they pass, there’s a good chance you’ve made a successful change.
* [Browser Tests](v<%= majorVersion %>/test.html)<br>
Run CoffeeScript’s test suite in your current browser.
* [CoffeeScript Issues](http://github.com/jashkenas/coffeescript/issues)<br>
Expand Down
Loading