diff --git a/documentation/coffee/block_comment.coffee b/documentation/coffee/block_comment.coffee index 3a313ade..431dfd95 100644 --- a/documentation/coffee/block_comment.coffee +++ b/documentation/coffee/block_comment.coffee @@ -1,5 +1,5 @@ ### -CoffeeScript Compiler v1.6.0 +CoffeeScript Compiler v1.6.1 Released under the MIT License ### diff --git a/documentation/docs/coffee-script.html b/documentation/docs/coffee-script.html index 5723c8e7..091b7a39 100644 --- a/documentation/docs/coffee-script.html +++ b/documentation/docs/coffee-script.html @@ -10,22 +10,18 @@ execute all scripts present in text/coffeescript tags.

{parser} = require './parser' helpers = require './helpers' vm = require 'vm' -sourcemap = require './sourcemap'

Load and run a CoffeeScript file for Node, stripping any BOMs.

loadFile = (module, filename) ->
+sourcemap = require './sourcemap'

Load and run a CoffeeScript file for Node, stripping any BOMs.

loadFile = (module, filename) ->
   raw = fs.readFileSync filename, 'utf8'
   stripped = if raw.charCodeAt(0) is 0xFEFF then raw.substring 1 else raw
   module._compile compile(stripped, {filename, literate: helpers.isLiterate filename}), filename
 
 if require.extensions
   for ext in ['.coffee', '.litcoffee', '.md', '.coffee.md']
-    require.extensions[ext] = loadFile

The current CoffeeScript version number.

exports.VERSION = '1.6.0'

Expose helpers for testing.

exports.helpers = require './helpers'
-
-baseFileName = (fileName) ->
-  extension = path.extname(fileName)
-  return path.basename fileName, extension

Compile CoffeeScript code to JavaScript, using the Coffee/Jison compiler.

+ require.extensions[ext] = loadFile

The current CoffeeScript version number.

exports.VERSION = '1.6.1'

Expose helpers for testing.

exports.helpers = helpers

Compile CoffeeScript code to JavaScript, using the Coffee/Jison compiler.

If options.sourceMap is specified, then options.filename must also be specified.

-

This returns a javascript string, unless options.sourceMap or options.returnObject are true, +

This returns a javascript string, unless options.sourceMap is passed, in which case this returns a `{js, v3SourceMap, sourceMap} object, where sourceMap is a sourcemap.coffee#SourceMap object, handy for doing programatic lookups.

exports.compile = compile = (code, options = {}) ->
@@ -33,13 +29,15 @@ lookups.

try if options.sourceMap - coffeeFile = path.basename options.filename - jsFile = baseFileName(options.filename) + ".js" + coffeeFile = helpers.baseFileName options.filename + jsFile = helpers.baseFileName(options.filename, yes) + ".js" sourceMap = new sourcemap.SourceMap() fragments = (parser.parse lexer.tokenize(code, options)).compileToFragments options currentLine = 0 + currentLine += 1 if options.header + currentLine += 1 if options.sourceMap currentColumn = 0 js = "" for fragment in fragments

Update the sourcemap with data from each fragment

      if sourceMap
@@ -60,7 +58,7 @@ lookups.

header = "Generated by CoffeeScript #{@VERSION}" js = "// #{header}\n#{js}" - if options.sourceMap or options.returnObject + if options.sourceMap answer = {js} if sourceMap answer.sourceMap = sourceMap diff --git a/documentation/docs/command.html b/documentation/docs/command.html index 3f3c71a0..2324bd1b 100644 --- a/documentation/docs/command.html +++ b/documentation/docs/command.html @@ -101,14 +101,18 @@ requested options. If evaluating the script directly sets __filenamecompileJoin() else compiled = CoffeeScript.compile t.input, t.options - t.output = compiled.js - t.sourceMap = compiled.v3SourceMap + t.output = compiled + if o.map + t.output = compiled.js + t.sourceMap = compiled.v3SourceMap CoffeeScript.emit 'success', task - if o.print then printLine t.output.trim() + if o.print + printLine t.output.trim() else if o.compile || o.map writeJs base, t.file, t.output, t.sourceMap - else if o.lint then lint t.file, t.output + else if o.lint + lint t.file, t.output catch err CoffeeScript.emit 'failure', err, task return if CoffeeScript.listeners('failure').length @@ -203,7 +207,7 @@ the compiled JS version as well.

fs.unlink jsPath, (err) -> throw err if err and err.code isnt 'ENOENT' timeLog "removed #{source}"

Get the corresponding output JavaScript path for a source file.

outputPath = (source, base, extension=".js") ->
-  basename  = path.basename source, source.match(/\.((lit)?coffee|coffee\.md)$/)?[0] or path.extname(source)
+  basename  = helpers.baseFileName source, yes
   srcDir    = path.dirname source
   baseDir   = if base is '.' then srcDir else srcDir.substring base.length
   dir       = if opts.output then path.join opts.output, baseDir else srcDir
@@ -219,7 +223,7 @@ same directory as the .js file.

< compile = -> if opts.compile js = ' ' if js.length <= 0 - if generatedSourceMap then js = "//@ sourceMappingURL=#{path.basename sourceMapPath}\n#{js}" + if generatedSourceMap then js = "//@ sourceMappingURL=#{helpers.baseFileName sourceMapPath}\n#{js}" fs.writeFile jsPath, js, (err) -> if err printLine err.message @@ -260,7 +264,6 @@ any errors or warnings that arise.

bare: opts.bare header: opts.compile sourceMap: opts.map - returnObject: yes }

Start up a new Node.js instance with the arguments in --nodejs passed to the node binary, preserving the other options.

forkNode = ->
   nodeArgs = opts.nodejs.split /\s+/
diff --git a/documentation/docs/helpers.html b/documentation/docs/helpers.html
index 9337135c..0ec8514e 100644
--- a/documentation/docs/helpers.html
+++ b/documentation/docs/helpers.html
@@ -51,6 +51,13 @@ updates that object's locationData.  The object is returned either way.

"#{locationData.first_line + 1}:#{locationData.first_column + 1}-" + "#{locationData.last_line + 1}:#{locationData.last_column + 1}" else - "No location data"

Determine if a filename represents a CoffeeScript file.

exports.isCoffee = (file) -> /\.((lit)?coffee|coffee\.md)$/.test file

Determine if a filename represents a Literate CoffeeScript file.

exports.isLiterate = (file) -> /\.(litcoffee|coffee\.md)$/.test file
+      "No location data"

A .coffee.md compatible version of basename, that returns the file sans-extension.

exports.baseFileName = (file, stripExt = no) ->
+  parts = file.split('/')
+  file = parts[parts.length - 1]
+  return file unless stripExt
+  parts = file.split('.')
+  parts.pop()
+  parts.pop() if parts[parts.length - 1] is 'coffee'
+  parts.join('.')

Determine if a filename represents a CoffeeScript file.

exports.isCoffee = (file) -> /\.((lit)?coffee|coffee\.md)$/.test file

Determine if a filename represents a Literate CoffeeScript file.

exports.isLiterate = (file) -> /\.(litcoffee|coffee\.md)$/.test file
 
 
\ No newline at end of file diff --git a/documentation/index.html.erb b/documentation/index.html.erb index d4710b6e..c9083377 100644 --- a/documentation/index.html.erb +++ b/documentation/index.html.erb @@ -139,7 +139,7 @@

Latest Version: - 1.6.0 + 1.6.1

@@ -969,7 +969,7 @@ Expressions
     
 
     

- CoffeeScript 1.6.0 and above include support for generating source maps, + CoffeeScript 1.6.1 and above include support for generating source maps, a way to tell your JavaScript engine what part of your CoffeeScript program matches up with the code being evaluated. Browsers that support it can automatically use source maps to show your original source code @@ -1194,7 +1194,7 @@ Expressions

- 1.6.0 + 1.6.1 March 5, 2013