Fixes #2766 -- incompatible line number API

This commit is contained in:
Jeremy Ashkenas 2013-03-05 10:19:21 +13:00
parent b4c12f6746
commit b2b801a78b
4 changed files with 17 additions and 12 deletions

View File

@ -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
};

View File

@ -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
};
};

View File

@ -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

View File

@ -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