Skip to content

Commit

Permalink
🐛 transpile + babel
Browse files Browse the repository at this point in the history
  • Loading branch information
princejwesley committed Nov 26, 2015
1 parent afb4f40 commit 9062ade
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/common/ReplInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let asyncWrapper = (code) => {
return `(async function() { let result = (${code}); return result; }())`;
};

let cook = (plain, transpile) => {
let cook = (plain) => {
let tplain = plain.trim();
let source = tplain.match(sourceMatcher);
if(source) {
Expand All @@ -24,7 +24,7 @@ let cook = (plain, transpile) => {

let output = plain;

if(!transpile && global.Mancy.preferences.asyncWrap && global.Mancy.preferences.lang === 'js') {
if(global.Mancy.preferences.asyncWrap && global.Mancy.preferences.lang === 'js') {
// bare await
let match = plain.match(awaitMatcher);
if(match && match[1].indexOf('async') === -1) {
Expand All @@ -34,23 +34,23 @@ let cook = (plain, transpile) => {

return {
local: false,
output: global.Mancy.preferences.babel && global.Mancy.preferences.lang === 'js' ? babelTransfrom(output, transpile) : output
output: global.Mancy.preferences.babel && global.Mancy.preferences.lang === 'js' ? babelTransfrom(output) : output
};
};

let babelTransfrom = (plain, transpile = false) => {
let babelTransfrom = (plain) => {
try {
return babel
.transform(plain, ReplConstants.BABEL_OPTIONS)
.code;
} catch(e) {
return transpile ? e : plain;
return plain;
}
}

let ReplInput = {
transform: (plain, transpile = false) => {
return cook(plain, transpile);
transform: (plain) => {
return cook(plain);
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/ReplActiveInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ export default class ReplActiveInput extends React.Component {
cli.$lastExpression = ReplOutput.none();
cli.context = ReplContext.getContext();
this.promptInput = text;
let {local, output, input} = ReplInput.transform(text, transpile);
let {local, output, input} = ReplInput.transform(text);

if(local) {
return this.addEntryAction(output, true, input, text);
Expand All @@ -388,7 +388,7 @@ export default class ReplActiveInput extends React.Component {
if(global.Mancy.session.lang !== 'js') {
cli.transpile(output, cli.context, this.transpileAndExecute);
} else {
this.transpileAndExecute(_.isError(output), output);
this.transpileAndExecute(_.isError(output) ? output : null, output);
}
return;
}
Expand Down

0 comments on commit 9062ade

Please sign in to comment.