mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
[CS2] Don’t require async/await support to run coffee (#4679)
* Get `coffee` command working again in Node 6, by converting the ‘await’ wrapper in the REPL to use a Promise instead of the ‘await’ keyword; add tests for REPL ‘await’ wrapper, including test to skip async tests if the runtime doesn’t support them * Code review * Let's support Node 6+ if we can
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
}
|
||||
})(),
|
||||
historyMaxInputSize: 10240,
|
||||
eval: async function(input, context, filename, cb) {
|
||||
eval: function(input, context, filename, cb) {
|
||||
var Assign, Block, Call, Code, Literal, Value, ast, err, isAsync, js, referencedVars, result, token, tokens;
|
||||
// XXX: multiline hack.
|
||||
input = input.replace(/\uFF00/g, '\n');
|
||||
@@ -71,10 +71,11 @@
|
||||
result = runInContext(js, context, filename);
|
||||
// Await an async result, if necessary
|
||||
if (isAsync) {
|
||||
result = (await result);
|
||||
if (!sawSIGINT) {
|
||||
cb(null, result);
|
||||
}
|
||||
result.then(function(resolvedResult) {
|
||||
if (!sawSIGINT) {
|
||||
return cb(null, resolvedResult);
|
||||
}
|
||||
});
|
||||
return sawSIGINT = false;
|
||||
} else {
|
||||
return cb(null, result);
|
||||
|
||||
Reference in New Issue
Block a user