mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Updated compile
This commit is contained in:
parent
cc98e99070
commit
beac56d4d5
5 changed files with 41 additions and 42 deletions
|
@ -46,7 +46,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
exports.run = function() {
|
exports.run = function() {
|
||||||
var _error, arg, args, e, i, len, ref, results;
|
var arg, args, e, error, i, len, ref, results;
|
||||||
global.__originalDirname = fs.realpathSync('.');
|
global.__originalDirname = fs.realpathSync('.');
|
||||||
process.chdir(cakefileDirectory(__originalDirname));
|
process.chdir(cakefileDirectory(__originalDirname));
|
||||||
args = process.argv.slice(2);
|
args = process.argv.slice(2);
|
||||||
|
@ -59,8 +59,8 @@
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
options = oparse.parse(args);
|
options = oparse.parse(args);
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
e = _error;
|
e = error;
|
||||||
return fatalError("" + e);
|
return fatalError("" + e);
|
||||||
}
|
}
|
||||||
ref = options["arguments"];
|
ref = options["arguments"];
|
||||||
|
|
|
@ -26,14 +26,14 @@
|
||||||
|
|
||||||
withPrettyErrors = function(fn) {
|
withPrettyErrors = function(fn) {
|
||||||
return function(code, options) {
|
return function(code, options) {
|
||||||
var _error, err;
|
var err, error;
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
options = {};
|
options = {};
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return fn.call(this, code, options);
|
return fn.call(this, code, options);
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
err = _error;
|
err = error;
|
||||||
if (typeof code !== 'string') {
|
if (typeof code !== 'string') {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
exports._compileFile = function(filename, sourceMap) {
|
exports._compileFile = function(filename, sourceMap) {
|
||||||
var _error, answer, err, raw, stripped;
|
var answer, err, error, raw, stripped;
|
||||||
if (sourceMap == null) {
|
if (sourceMap == null) {
|
||||||
sourceMap = false;
|
sourceMap = false;
|
||||||
}
|
}
|
||||||
|
@ -229,8 +229,8 @@
|
||||||
sourceMap: sourceMap,
|
sourceMap: sourceMap,
|
||||||
literate: helpers.isLiterate(filename)
|
literate: helpers.isLiterate(filename)
|
||||||
});
|
});
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
err = _error;
|
err = error;
|
||||||
throw helpers.updateSyntaxError(err, stripped, filename);
|
throw helpers.updateSyntaxError(err, stripped, filename);
|
||||||
}
|
}
|
||||||
return answer;
|
return answer;
|
||||||
|
|
|
@ -112,14 +112,14 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
compilePath = function(source, topLevel, base) {
|
compilePath = function(source, topLevel, base) {
|
||||||
var _error, _error1, _error2, code, err, file, files, i, len, results, stats;
|
var code, err, error, error1, error2, file, files, i, len, results, stats;
|
||||||
if (indexOf.call(sources, source) >= 0 || watchedDirs[source] || !topLevel && (notSources[source] || hidden(source))) {
|
if (indexOf.call(sources, source) >= 0 || watchedDirs[source] || !topLevel && (notSources[source] || hidden(source))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
stats = fs.statSync(source);
|
stats = fs.statSync(source);
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
err = _error;
|
err = error;
|
||||||
if (err.code === 'ENOENT') {
|
if (err.code === 'ENOENT') {
|
||||||
console.error("File not found: " + source);
|
console.error("File not found: " + source);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
@ -140,8 +140,8 @@
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
files = fs.readdirSync(source);
|
files = fs.readdirSync(source);
|
||||||
} catch (_error1) {
|
} catch (error1) {
|
||||||
err = _error1;
|
err = error1;
|
||||||
if (err.code === 'ENOENT') {
|
if (err.code === 'ENOENT') {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -163,8 +163,8 @@
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
code = fs.readFileSync(source);
|
code = fs.readFileSync(source);
|
||||||
} catch (_error2) {
|
} catch (error2) {
|
||||||
err = _error2;
|
err = error2;
|
||||||
if (err.code === 'ENOENT') {
|
if (err.code === 'ENOENT') {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -178,7 +178,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
findDirectoryIndex = function(source) {
|
findDirectoryIndex = function(source) {
|
||||||
var _error, err, ext, i, index, len, ref1;
|
var err, error, ext, i, index, len, ref1;
|
||||||
ref1 = CoffeeScript.FILE_EXTENSIONS;
|
ref1 = CoffeeScript.FILE_EXTENSIONS;
|
||||||
for (i = 0, len = ref1.length; i < len; i++) {
|
for (i = 0, len = ref1.length; i < len; i++) {
|
||||||
ext = ref1[i];
|
ext = ref1[i];
|
||||||
|
@ -187,8 +187,8 @@
|
||||||
if ((fs.statSync(index)).isFile()) {
|
if ((fs.statSync(index)).isFile()) {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
err = _error;
|
err = error;
|
||||||
if (err.code !== 'ENOENT') {
|
if (err.code !== 'ENOENT') {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
compileScript = function(file, input, base) {
|
compileScript = function(file, input, base) {
|
||||||
var _error, compiled, err, message, o, options, t, task;
|
var compiled, err, error, message, o, options, t, task;
|
||||||
if (base == null) {
|
if (base == null) {
|
||||||
base = null;
|
base = null;
|
||||||
}
|
}
|
||||||
|
@ -242,8 +242,8 @@
|
||||||
return writeJs(base, t.file, t.output, options.jsPath, t.sourceMap);
|
return writeJs(base, t.file, t.output, options.jsPath, t.sourceMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
err = _error;
|
err = error;
|
||||||
CoffeeScript.emit('failure', err, task);
|
CoffeeScript.emit('failure', err, task);
|
||||||
if (CoffeeScript.listeners('failure').length) {
|
if (CoffeeScript.listeners('failure').length) {
|
||||||
return;
|
return;
|
||||||
|
@ -289,12 +289,12 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
watch = function(source, base) {
|
watch = function(source, base) {
|
||||||
var _error, compile, compileTimeout, err, prevStats, rewatch, startWatcher, watchErr, watcher;
|
var compile, compileTimeout, err, error, prevStats, rewatch, startWatcher, watchErr, watcher;
|
||||||
watcher = null;
|
watcher = null;
|
||||||
prevStats = null;
|
prevStats = null;
|
||||||
compileTimeout = null;
|
compileTimeout = null;
|
||||||
watchErr = function(err) {
|
watchErr = function(err) {
|
||||||
var _error;
|
var error;
|
||||||
if (err.code !== 'ENOENT') {
|
if (err.code !== 'ENOENT') {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@
|
||||||
try {
|
try {
|
||||||
rewatch();
|
rewatch();
|
||||||
return compile();
|
return compile();
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
removeSource(source, base);
|
removeSource(source, base);
|
||||||
return compileJoin();
|
return compileJoin();
|
||||||
}
|
}
|
||||||
|
@ -346,14 +346,14 @@
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
return startWatcher();
|
return startWatcher();
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
err = _error;
|
err = error;
|
||||||
return watchErr(err);
|
return watchErr(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
watchDir = function(source, base) {
|
watchDir = function(source, base) {
|
||||||
var _error, err, readdirTimeout, startWatcher, stopWatcher, watcher;
|
var err, error, readdirTimeout, startWatcher, stopWatcher, watcher;
|
||||||
watcher = null;
|
watcher = null;
|
||||||
readdirTimeout = null;
|
readdirTimeout = null;
|
||||||
startWatcher = function() {
|
startWatcher = function() {
|
||||||
|
@ -365,11 +365,11 @@
|
||||||
}).on('change', function() {
|
}).on('change', function() {
|
||||||
clearTimeout(readdirTimeout);
|
clearTimeout(readdirTimeout);
|
||||||
return readdirTimeout = wait(25, function() {
|
return readdirTimeout = wait(25, function() {
|
||||||
var _error, err, file, files, i, len, results;
|
var err, error, file, files, i, len, results;
|
||||||
try {
|
try {
|
||||||
files = fs.readdirSync(source);
|
files = fs.readdirSync(source);
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
err = _error;
|
err = error;
|
||||||
if (err.code !== 'ENOENT') {
|
if (err.code !== 'ENOENT') {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -391,8 +391,8 @@
|
||||||
watchedDirs[source] = true;
|
watchedDirs[source] = true;
|
||||||
try {
|
try {
|
||||||
return startWatcher();
|
return startWatcher();
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
err = _error;
|
err = error;
|
||||||
if (err.code !== 'ENOENT') {
|
if (err.code !== 'ENOENT') {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -429,11 +429,11 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
silentUnlink = function(path) {
|
silentUnlink = function(path) {
|
||||||
var _error, err, ref1;
|
var err, error, ref1;
|
||||||
try {
|
try {
|
||||||
return fs.unlinkSync(path);
|
return fs.unlinkSync(path);
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
err = _error;
|
err = error;
|
||||||
if ((ref1 = err.code) !== 'ENOENT' && ref1 !== 'EPERM') {
|
if ((ref1 = err.code) !== 'ENOENT' && ref1 !== 'EPERM') {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2684,11 +2684,10 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
Try.prototype.compileNode = function(o) {
|
Try.prototype.compileNode = function(o) {
|
||||||
var catchPart, ensurePart, generatedErrorVariableName, placeholder, scope, tryPart;
|
var catchPart, ensurePart, generatedErrorVariableName, placeholder, tryPart;
|
||||||
o.indent += TAB;
|
o.indent += TAB;
|
||||||
scope = o.scope;
|
|
||||||
tryPart = this.attempt.compileToFragments(o, LEVEL_TOP);
|
tryPart = this.attempt.compileToFragments(o, LEVEL_TOP);
|
||||||
catchPart = this.recovery ? (generatedErrorVariableName = scope.freeVariable('error'), placeholder = new Literal(generatedErrorVariableName), this.errorVariable ? this.recovery.unshift(new Assign(this.errorVariable, placeholder)) : void 0, [].concat(this.makeCode(" catch ("), placeholder.compileToFragments(o), this.makeCode(") {\n"), this.recovery.compileToFragments(o, LEVEL_TOP), this.makeCode("\n" + this.tab + "}"))) : !(this.ensure || this.recovery) ? [this.makeCode(" catch (" + generatedErrorVariableName + ") {}")] : [];
|
catchPart = this.recovery ? (generatedErrorVariableName = o.scope.freeVariable('error'), placeholder = new Literal(generatedErrorVariableName), this.errorVariable ? this.recovery.unshift(new Assign(this.errorVariable, placeholder)) : void 0, [].concat(this.makeCode(" catch ("), placeholder.compileToFragments(o), this.makeCode(") {\n"), this.recovery.compileToFragments(o, LEVEL_TOP), this.makeCode("\n" + this.tab + "}"))) : !(this.ensure || this.recovery) ? [this.makeCode(" catch (" + generatedErrorVariableName + ") {}")] : [];
|
||||||
ensurePart = this.ensure ? [].concat(this.makeCode(" finally {\n"), this.ensure.compileToFragments(o, LEVEL_TOP), this.makeCode("\n" + this.tab + "}")) : [];
|
ensurePart = this.ensure ? [].concat(this.makeCode(" finally {\n"), this.ensure.compileToFragments(o, LEVEL_TOP), this.makeCode("\n" + this.tab + "}")) : [];
|
||||||
return [].concat(this.makeCode(this.tab + "try {\n"), tryPart, this.makeCode("\n" + this.tab + "}"), catchPart, ensurePart);
|
return [].concat(this.makeCode(this.tab + "try {\n"), tryPart, this.makeCode("\n" + this.tab + "}"), catchPart, ensurePart);
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
historyFile: process.env.HOME ? path.join(process.env.HOME, '.coffee_history') : void 0,
|
historyFile: process.env.HOME ? path.join(process.env.HOME, '.coffee_history') : void 0,
|
||||||
historyMaxInputSize: 10240,
|
historyMaxInputSize: 10240,
|
||||||
"eval": function(input, context, filename, cb) {
|
"eval": function(input, context, filename, cb) {
|
||||||
var Assign, Block, Literal, Value, _error, ast, err, js, ref1, referencedVars, token, tokens;
|
var Assign, Block, Literal, Value, ast, err, error, js, ref1, referencedVars, token, tokens;
|
||||||
input = input.replace(/\uFF00/g, '\n');
|
input = input.replace(/\uFF00/g, '\n');
|
||||||
input = input.replace(/^\(([\s\S]*)\n\)$/m, '$1');
|
input = input.replace(/^\(([\s\S]*)\n\)$/m, '$1');
|
||||||
ref1 = require('./nodes'), Block = ref1.Block, Assign = ref1.Assign, Value = ref1.Value, Literal = ref1.Literal;
|
ref1 = require('./nodes'), Block = ref1.Block, Assign = ref1.Assign, Value = ref1.Value, Literal = ref1.Literal;
|
||||||
|
@ -44,8 +44,8 @@
|
||||||
referencedVars: referencedVars
|
referencedVars: referencedVars
|
||||||
});
|
});
|
||||||
return cb(null, runInContext(js, context, filename));
|
return cb(null, runInContext(js, context, filename));
|
||||||
} catch (_error) {
|
} catch (error) {
|
||||||
err = _error;
|
err = error;
|
||||||
updateSyntaxError(err, input);
|
updateSyntaxError(err, input);
|
||||||
return cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue