mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
(Aside: For historical reasons we do make the filename extension optional, which is a deeply regrettable accident of history that I would not repeat, given the chance.)
This commit is contained in:
parent
3f23be2854
commit
c6f30935a8
2 changed files with 11 additions and 23 deletions
|
@ -91,27 +91,20 @@
|
|||
|
||||
compilePath = function(source, topLevel, base) {
|
||||
return fs.stat(source, function(err, stats) {
|
||||
var _ref1, _ref2;
|
||||
var _ref1;
|
||||
if (err && err.code !== 'ENOENT') {
|
||||
throw err;
|
||||
}
|
||||
if ((err != null ? err.code : void 0) === 'ENOENT') {
|
||||
if (topLevel && source && (_ref1 = path.extname(source), __indexOf.call(coffee_exts, _ref1) < 0)) {
|
||||
source = sources[sources.indexOf(source)] = "" + source + ".coffee";
|
||||
return compilePath(source, topLevel, base);
|
||||
}
|
||||
if (topLevel) {
|
||||
console.error("File not found: " + source);
|
||||
process.exit(1);
|
||||
}
|
||||
return;
|
||||
console.error("File not found: " + source);
|
||||
process.exit(1);
|
||||
}
|
||||
if (stats.isDirectory() && path.dirname(source) !== 'node_modules') {
|
||||
if (opts.watch) {
|
||||
watchDir(source, base);
|
||||
}
|
||||
return fs.readdir(source, function(err, files) {
|
||||
var file, index, _ref2, _ref3;
|
||||
var file, index, _ref1, _ref2;
|
||||
if (err && err.code !== 'ENOENT') {
|
||||
throw err;
|
||||
}
|
||||
|
@ -122,7 +115,7 @@
|
|||
files = files.filter(function(file) {
|
||||
return !hidden(file);
|
||||
});
|
||||
[].splice.apply(sources, [index, index - index + 1].concat(_ref2 = (function() {
|
||||
[].splice.apply(sources, [index, index - index + 1].concat(_ref1 = (function() {
|
||||
var _i, _len, _results;
|
||||
_results = [];
|
||||
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
||||
|
@ -130,15 +123,15 @@
|
|||
_results.push(path.join(source, file));
|
||||
}
|
||||
return _results;
|
||||
})())), _ref2;
|
||||
[].splice.apply(sourceCode, [index, index - index + 1].concat(_ref3 = files.map(function() {
|
||||
})())), _ref1;
|
||||
[].splice.apply(sourceCode, [index, index - index + 1].concat(_ref2 = files.map(function() {
|
||||
return null;
|
||||
}))), _ref3;
|
||||
}))), _ref2;
|
||||
return files.forEach(function(file) {
|
||||
return compilePath(path.join(source, file), false, base);
|
||||
});
|
||||
});
|
||||
} else if (topLevel || (_ref2 = path.extname(source), __indexOf.call(coffee_exts, _ref2) >= 0)) {
|
||||
} else if (topLevel || (_ref1 = path.extname(source), __indexOf.call(coffee_exts, _ref1) >= 0)) {
|
||||
if (opts.watch) {
|
||||
watch(source, base);
|
||||
}
|
||||
|
|
|
@ -85,13 +85,8 @@ 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 and path.extname(source) not in coffee_exts
|
||||
source = sources[sources.indexOf(source)] = "#{source}.coffee"
|
||||
return compilePath source, topLevel, base
|
||||
if topLevel
|
||||
console.error "File not found: #{source}"
|
||||
process.exit 1
|
||||
return
|
||||
console.error "File not found: #{source}"
|
||||
process.exit 1
|
||||
if stats.isDirectory() and path.dirname(source) isnt 'node_modules'
|
||||
watchDir source, base if opts.watch
|
||||
fs.readdir source, (err, files) ->
|
||||
|
|
Loading…
Reference in a new issue