mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-01-14 17:27:59 -05:00
CoffeeScript 1.6.1
This commit is contained in:
@@ -25,7 +25,7 @@ if require.extensions
|
||||
require.extensions[ext] = loadFile
|
||||
|
||||
# The current CoffeeScript version number.
|
||||
exports.VERSION = '1.6.0'
|
||||
exports.VERSION = '1.6.1'
|
||||
|
||||
# Expose helpers for testing.
|
||||
exports.helpers = helpers
|
||||
@@ -43,14 +43,15 @@ exports.compile = compile = (code, options = {}) ->
|
||||
try
|
||||
|
||||
if options.sourceMap
|
||||
coffeeFile = path.basename options.filename
|
||||
jsFile = helpers.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
|
||||
|
||||
# Two lines of comments will start the JS file.
|
||||
currentLine = 2
|
||||
currentLine = 0
|
||||
currentLine += 1 if options.header
|
||||
currentLine += 1 if options.sourceMap
|
||||
currentColumn = 0
|
||||
js = ""
|
||||
for fragment in fragments
|
||||
|
||||
@@ -251,7 +251,7 @@ removeSource = (source, base, removeJs) ->
|
||||
|
||||
# Get the corresponding output JavaScript path for a source file.
|
||||
outputPath = (source, base, extension=".js") ->
|
||||
basename = helpers.baseFileName 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
|
||||
@@ -270,7 +270,7 @@ writeJs = (base, sourcePath, js, generatedSourceMap = null) ->
|
||||
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
|
||||
|
||||
@@ -93,9 +93,10 @@ exports.locationDataToString = (obj) ->
|
||||
"No location data"
|
||||
|
||||
# A `.coffee.md` compatible version of `basename`, that returns the file sans-extension.
|
||||
exports.baseFileName = (file) ->
|
||||
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'
|
||||
|
||||
Reference in New Issue
Block a user