mirror of https://github.com/embarklabs/embark.git
fix one with variable
This commit is contained in:
parent
a0b06c6197
commit
326e12d23a
|
@ -43,16 +43,15 @@ class CodeRunner {
|
||||||
}
|
}
|
||||||
const awaitIdx = code.indexOf('await');
|
const awaitIdx = code.indexOf('await');
|
||||||
if (awaitIdx > -1) {
|
if (awaitIdx > -1) {
|
||||||
|
if (awaitIdx < 2) {
|
||||||
let end = code.length;
|
let end = code.length;
|
||||||
if (code[end - 1] === ';') {
|
if (code[end - 1] === ';') {
|
||||||
end--; // Remove the `;` because we add function calls
|
end--; // Remove the `;` because we add function calls
|
||||||
}
|
}
|
||||||
if (awaitIdx < 2) {
|
|
||||||
code = code.substring(5, end); // remove await keyword
|
code = code.substring(5, end); // remove await keyword
|
||||||
code += '.then(console.log).catch(console.error);'; // Add promise catch
|
code += '.then(console.log).catch(console.error);'; // Add promise catch
|
||||||
} else {
|
} else {
|
||||||
code = code.substring(0, end); // remove ending `;`
|
code = `(async function() {${code}})();`;
|
||||||
code = `(async function() {${code}.then(console.log);})();`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let result = RunCode.doEval(code);
|
let result = RunCode.doEval(code);
|
||||||
|
|
Loading…
Reference in New Issue