mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
add litcoffee to supported file formats
This commit is contained in:
parent
ba08a21d21
commit
27551b23f3
2 changed files with 17 additions and 12 deletions
|
@ -1,6 +1,7 @@
|
|||
// Generated by CoffeeScript 1.5.0-pre
|
||||
(function() {
|
||||
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, exists, forkNode, fs, helpers, hidden, joinTimeout, lint, loadRequires, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, sourceCode, sources, spawn, timeLog, unwatchDir, usage, version, wait, watch, watchDir, watchers, writeJs, _ref;
|
||||
var BANNER, CoffeeScript, EventEmitter, SWITCHES, coffee_exts, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, exists, forkNode, fs, helpers, hidden, joinTimeout, lint, loadRequires, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, sourceCode, sources, spawn, timeLog, unwatchDir, usage, version, wait, watch, watchDir, watchers, writeJs, _ref,
|
||||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
|
@ -48,6 +49,8 @@
|
|||
|
||||
optionParser = null;
|
||||
|
||||
coffee_exts = ['.coffee', '.litcoffee'];
|
||||
|
||||
exports.run = function() {
|
||||
var literals, source, _i, _len, _results;
|
||||
parseOptions();
|
||||
|
@ -92,11 +95,12 @@
|
|||
|
||||
compilePath = function(source, topLevel, base) {
|
||||
return fs.stat(source, function(err, stats) {
|
||||
var _ref1, _ref2;
|
||||
if (err && err.code !== 'ENOENT') {
|
||||
throw err;
|
||||
}
|
||||
if ((err != null ? err.code : void 0) === 'ENOENT') {
|
||||
if (topLevel && source.slice(-7) !== '.coffee') {
|
||||
if (topLevel && (_ref1 = source.slice(-7), __indexOf.call(coffee_exts, _ref1) < 0)) {
|
||||
source = sources[sources.indexOf(source)] = "" + source + ".coffee";
|
||||
return compilePath(source, topLevel, base);
|
||||
}
|
||||
|
@ -111,7 +115,7 @@
|
|||
watchDir(source, base);
|
||||
}
|
||||
return fs.readdir(source, function(err, files) {
|
||||
var file, index, _ref1, _ref2;
|
||||
var file, index, _ref2, _ref3;
|
||||
if (err && err.code !== 'ENOENT') {
|
||||
throw err;
|
||||
}
|
||||
|
@ -122,7 +126,7 @@
|
|||
files = files.filter(function(file) {
|
||||
return !hidden(file);
|
||||
});
|
||||
[].splice.apply(sources, [index, index - index + 1].concat(_ref1 = (function() {
|
||||
[].splice.apply(sources, [index, index - index + 1].concat(_ref2 = (function() {
|
||||
var _i, _len, _results;
|
||||
_results = [];
|
||||
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
||||
|
@ -130,15 +134,15 @@
|
|||
_results.push(path.join(source, file));
|
||||
}
|
||||
return _results;
|
||||
})())), _ref1;
|
||||
[].splice.apply(sourceCode, [index, index - index + 1].concat(_ref2 = files.map(function() {
|
||||
})())), _ref2;
|
||||
[].splice.apply(sourceCode, [index, index - index + 1].concat(_ref3 = files.map(function() {
|
||||
return null;
|
||||
}))), _ref2;
|
||||
}))), _ref3;
|
||||
return files.forEach(function(file) {
|
||||
return compilePath(path.join(source, file), false, base);
|
||||
});
|
||||
});
|
||||
} else if (topLevel || path.extname(source) === '.coffee') {
|
||||
} else if (topLevel || (_ref2 = path.extname(source), __indexOf.call(coffee_exts, _ref2) >= 0)) {
|
||||
if (opts.watch) {
|
||||
watch(source, base);
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ sourceCode = []
|
|||
notSources = {}
|
||||
watchers = {}
|
||||
optionParser = null
|
||||
coffee_exts = ['.coffee', '.litcoffee']
|
||||
|
||||
# Run `coffee` by parsing passed options and determining what action to take.
|
||||
# Many flags cause us to divert before compiling anything. Flags passed after
|
||||
|
@ -81,13 +82,13 @@ exports.run = ->
|
|||
compilePath source, yes, path.normalize source
|
||||
|
||||
# Compile a path, which could be a script or a directory. If a directory
|
||||
# is passed, recursively compile all '.coffee' extension source files in it
|
||||
# and all subdirectories.
|
||||
# is passed, recursively compile all '.coffee' and '.litcoffee' extension source
|
||||
# files in it and all subdirectories.
|
||||
compilePath = (source, topLevel, base) ->
|
||||
fs.stat source, (err, stats) ->
|
||||
throw err if err and err.code isnt 'ENOENT'
|
||||
if err?.code is 'ENOENT'
|
||||
if topLevel and source[-7..] isnt '.coffee'
|
||||
if topLevel and source[-7..] not in coffee_exts
|
||||
source = sources[sources.indexOf(source)] = "#{source}.coffee"
|
||||
return compilePath source, topLevel, base
|
||||
if topLevel
|
||||
|
@ -105,7 +106,7 @@ compilePath = (source, topLevel, base) ->
|
|||
sourceCode[index..index] = files.map -> null
|
||||
files.forEach (file) ->
|
||||
compilePath (path.join source, file), no, base
|
||||
else if topLevel or path.extname(source) is '.coffee'
|
||||
else if topLevel or path.extname(source) in coffee_exts
|
||||
watch source, base if opts.watch
|
||||
fs.readFile source, (err, code) ->
|
||||
throw err if err and err.code isnt 'ENOENT'
|
||||
|
|
Loading…
Add table
Reference in a new issue