From b2b801a78bf7f495a88667410f54f78cbf2a8509 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Tue, 5 Mar 2013 10:19:21 +1300 Subject: [PATCH] Fixes #2766 -- incompatible line number API --- lib/coffee-script/coffee-script.js | 2 +- lib/coffee-script/command.js | 10 ++++++---- src/coffee-script.coffee | 4 ++-- src/command.coffee | 13 ++++++++----- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/coffee-script/coffee-script.js b/lib/coffee-script/coffee-script.js index 24e90267..66f4acc5 100644 --- a/lib/coffee-script/coffee-script.js +++ b/lib/coffee-script/coffee-script.js @@ -85,7 +85,7 @@ header = "Generated by CoffeeScript " + this.VERSION; js = "// " + header + "\n" + js; } - if (options.sourceMap || options.returnObject) { + if (options.sourceMap) { answer = { js: js }; diff --git a/lib/coffee-script/command.js b/lib/coffee-script/command.js index 7c8c4332..beb55d8a 100644 --- a/lib/coffee-script/command.js +++ b/lib/coffee-script/command.js @@ -169,8 +169,11 @@ return compileJoin(); } else { compiled = CoffeeScript.compile(t.input, t.options); - t.output = compiled.js; - t.sourceMap = compiled.v3SourceMap; + t.output = compiled; + if (o.sourceMap) { + t.output = compiled.js; + t.sourceMap = compiled.v3SourceMap; + } CoffeeScript.emit('success', task); if (o.print) { return printLine(t.output.trim()); @@ -476,8 +479,7 @@ literate: helpers.isLiterate(filename), bare: opts.bare, header: opts.compile, - sourceMap: opts.map, - returnObject: true + sourceMap: opts.map }; }; diff --git a/src/coffee-script.coffee b/src/coffee-script.coffee index 60cfd82a..6d749437 100644 --- a/src/coffee-script.coffee +++ b/src/coffee-script.coffee @@ -38,7 +38,7 @@ baseFileName = (fileName) -> # # 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. @@ -79,7 +79,7 @@ exports.compile = compile = (code, options = {}) -> 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/src/command.coffee b/src/command.coffee index 399baf33..00fd4cc6 100644 --- a/src/command.coffee +++ b/src/command.coffee @@ -126,14 +126,18 @@ compileScript = (file, input, base) -> compileJoin() else compiled = CoffeeScript.compile t.input, t.options - t.output = compiled.js - t.sourceMap = compiled.v3SourceMap + t.output = compiled + if o.sourceMap + 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 @@ -325,7 +329,6 @@ compileOptions = (filename) -> 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