1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Moving path dependency back into 'command'

This commit is contained in:
Jeremy Ashkenas 2013-03-01 12:50:42 +13:00
parent d70d71f574
commit 68718b6938
4 changed files with 6 additions and 19 deletions

View file

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

View file

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

View file

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

View file

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