diff --git a/lib/coffee-script/command.js b/lib/coffee-script/command.js index 6e6b4d99..d8929b72 100644 --- a/lib/coffee-script/command.js +++ b/lib/coffee-script/command.js @@ -365,12 +365,12 @@ }; outputPath = function(source, base) { - var baseDir, dir, filename, srcDir; - filename = helpers.getBasename(source) + '.js'; + var baseDir, basename, dir, srcDir, _ref1; + basename = path.basename(source, ((_ref1 = source.match(/\.((lit)?coffee|coffee\.md)$/)) != null ? _ref1[0] : void 0) || path.extname(source)); srcDir = path.dirname(source); baseDir = base === '.' ? srcDir : srcDir.substring(base.length); dir = opts.output ? path.join(opts.output, baseDir) : srcDir; - return path.join(dir, filename); + return path.join(dir, basename + '.js'); }; writeJs = function(source, js, base) { diff --git a/lib/coffee-script/helpers.js b/lib/coffee-script/helpers.js index f215e8c8..08ef7ee8 100644 --- a/lib/coffee-script/helpers.js +++ b/lib/coffee-script/helpers.js @@ -1,8 +1,6 @@ // Generated by CoffeeScript 1.5.0 (function() { - var buildLocationData, extend, flatten, path, _ref; - - path = require('path'); + var buildLocationData, extend, flatten, _ref; exports.starts = function(string, literal, start) { return literal === string.substr(start, literal.length); @@ -131,9 +129,4 @@ return /\.(litcoffee|coffee\.md)$/.test(file); }; - exports.getBasename = function(file) { - var _ref1; - return path.basename(file, (file != null ? typeof file.match === "function" ? (_ref1 = file.match(/\.((lit)?coffee|coffee\.md)$/)) != null ? _ref1[0] : void 0 : void 0 : void 0) || path.extname(file)); - }; - }).call(this); diff --git a/src/command.coffee b/src/command.coffee index 3fa4b9a2..9c0ba515 100644 --- a/src/command.coffee +++ b/src/command.coffee @@ -242,11 +242,11 @@ removeSource = (source, base, removeJs) -> # Get the corresponding output JavaScript path for a source file. outputPath = (source, base) -> - filename = helpers.getBasename(source) + '.js' + basename = path.basename source, source.match(/\.((lit)?coffee|coffee\.md)$/)?[0] or path.extname(source) 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 - path.join dir, filename + path.join dir, basename + '.js' # Write out a JavaScript source file with the compiled code. By default, files # are written out in `cwd` as `.js` files with the same name, but the output diff --git a/src/helpers.coffee b/src/helpers.coffee index 29606e91..5c1dfab4 100644 --- a/src/helpers.coffee +++ b/src/helpers.coffee @@ -2,8 +2,6 @@ # the **Lexer**, **Rewriter**, and the **Nodes**. Merge objects, flatten # arrays, count characters, that sort of thing. -path = require 'path' - # Peek at the beginning of a given string to see if it matches a sequence. exports.starts = (string, literal, start) -> literal is string.substr start, literal.length @@ -100,8 +98,4 @@ 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 -# Extract the basename from a source file name, accounting for all possible -# CoffeeScript extensions. -exports.getBasename = (file) -> path.basename file, file?.match?(/\.((lit)?coffee|coffee\.md)$/)?[0] or path.extname(file) -