Updated compile

This commit is contained in:
Bruno Bernardino 2015-08-16 21:34:22 +01:00
parent cc98e99070
commit beac56d4d5
5 changed files with 41 additions and 42 deletions

View File

@ -46,7 +46,7 @@
});
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('.');
process.chdir(cakefileDirectory(__originalDirname));
args = process.argv.slice(2);
@ -59,8 +59,8 @@
}
try {
options = oparse.parse(args);
} catch (_error) {
e = _error;
} catch (error) {
e = error;
return fatalError("" + e);
}
ref = options["arguments"];

View File

@ -26,14 +26,14 @@
withPrettyErrors = function(fn) {
return function(code, options) {
var _error, err;
var err, error;
if (options == null) {
options = {};
}
try {
return fn.call(this, code, options);
} catch (_error) {
err = _error;
} catch (error) {
err = error;
if (typeof code !== 'string') {
throw err;
}
@ -217,7 +217,7 @@
}
exports._compileFile = function(filename, sourceMap) {
var _error, answer, err, raw, stripped;
var answer, err, error, raw, stripped;
if (sourceMap == null) {
sourceMap = false;
}
@ -229,8 +229,8 @@
sourceMap: sourceMap,
literate: helpers.isLiterate(filename)
});
} catch (_error) {
err = _error;
} catch (error) {
err = error;
throw helpers.updateSyntaxError(err, stripped, filename);
}
return answer;

View File

@ -112,14 +112,14 @@
};
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))) {
return;
}
try {
stats = fs.statSync(source);
} catch (_error) {
err = _error;
} catch (error) {
err = error;
if (err.code === 'ENOENT') {
console.error("File not found: " + source);
process.exit(1);
@ -140,8 +140,8 @@
}
try {
files = fs.readdirSync(source);
} catch (_error1) {
err = _error1;
} catch (error1) {
err = error1;
if (err.code === 'ENOENT') {
return;
} else {
@ -163,8 +163,8 @@
}
try {
code = fs.readFileSync(source);
} catch (_error2) {
err = _error2;
} catch (error2) {
err = error2;
if (err.code === 'ENOENT') {
return;
} else {
@ -178,7 +178,7 @@
};
findDirectoryIndex = function(source) {
var _error, err, ext, i, index, len, ref1;
var err, error, ext, i, index, len, ref1;
ref1 = CoffeeScript.FILE_EXTENSIONS;
for (i = 0, len = ref1.length; i < len; i++) {
ext = ref1[i];
@ -187,8 +187,8 @@
if ((fs.statSync(index)).isFile()) {
return index;
}
} catch (_error) {
err = _error;
} catch (error) {
err = error;
if (err.code !== 'ENOENT') {
throw err;
}
@ -199,7 +199,7 @@
};
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) {
base = null;
}
@ -242,8 +242,8 @@
return writeJs(base, t.file, t.output, options.jsPath, t.sourceMap);
}
}
} catch (_error) {
err = _error;
} catch (error) {
err = error;
CoffeeScript.emit('failure', err, task);
if (CoffeeScript.listeners('failure').length) {
return;
@ -289,12 +289,12 @@
};
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;
prevStats = null;
compileTimeout = null;
watchErr = function(err) {
var _error;
var error;
if (err.code !== 'ENOENT') {
throw err;
}
@ -304,7 +304,7 @@
try {
rewatch();
return compile();
} catch (_error) {
} catch (error) {
removeSource(source, base);
return compileJoin();
}
@ -346,14 +346,14 @@
};
try {
return startWatcher();
} catch (_error) {
err = _error;
} catch (error) {
err = error;
return watchErr(err);
}
};
watchDir = function(source, base) {
var _error, err, readdirTimeout, startWatcher, stopWatcher, watcher;
var err, error, readdirTimeout, startWatcher, stopWatcher, watcher;
watcher = null;
readdirTimeout = null;
startWatcher = function() {
@ -365,11 +365,11 @@
}).on('change', function() {
clearTimeout(readdirTimeout);
return readdirTimeout = wait(25, function() {
var _error, err, file, files, i, len, results;
var err, error, file, files, i, len, results;
try {
files = fs.readdirSync(source);
} catch (_error) {
err = _error;
} catch (error) {
err = error;
if (err.code !== 'ENOENT') {
throw err;
}
@ -391,8 +391,8 @@
watchedDirs[source] = true;
try {
return startWatcher();
} catch (_error) {
err = _error;
} catch (error) {
err = error;
if (err.code !== 'ENOENT') {
throw err;
}
@ -429,11 +429,11 @@
};
silentUnlink = function(path) {
var _error, err, ref1;
var err, error, ref1;
try {
return fs.unlinkSync(path);
} catch (_error) {
err = _error;
} catch (error) {
err = error;
if ((ref1 = err.code) !== 'ENOENT' && ref1 !== 'EPERM') {
throw err;
}

View File

@ -2684,11 +2684,10 @@
};
Try.prototype.compileNode = function(o) {
var catchPart, ensurePart, generatedErrorVariableName, placeholder, scope, tryPart;
var catchPart, ensurePart, generatedErrorVariableName, placeholder, tryPart;
o.indent += TAB;
scope = o.scope;
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 + "}")) : [];
return [].concat(this.makeCode(this.tab + "try {\n"), tryPart, this.makeCode("\n" + this.tab + "}"), catchPart, ensurePart);
};

View File

@ -19,7 +19,7 @@
historyFile: process.env.HOME ? path.join(process.env.HOME, '.coffee_history') : void 0,
historyMaxInputSize: 10240,
"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(/^\(([\s\S]*)\n\)$/m, '$1');
ref1 = require('./nodes'), Block = ref1.Block, Assign = ref1.Assign, Value = ref1.Value, Literal = ref1.Literal;
@ -44,8 +44,8 @@
referencedVars: referencedVars
});
return cb(null, runInContext(js, context, filename));
} catch (_error) {
err = _error;
} catch (error) {
err = error;
updateSyntaxError(err, input);
return cb(err);
}