allow running js from the CLI

pull/426/head
yann300 4 years ago
parent ad374eb268
commit fde1f778b2
  1. 16
      apps/remix-ide/src/app/panels/terminal.js

@ -475,6 +475,20 @@ class Terminal extends Plugin {
return self._view.el
function wrapScript (script) {
return `
try {
const ret = ${script};
if (ret instanceof Promise) {
ret.then((result) => { console.log(result) }).catch((error) => { console.log(error) })
} else {
console.log(ret)
}
} catch (e) {
console.log(error)
}
`
}
function change (event) {
if (self._components.autoCompletePopup.handleAutoComplete(
event,
@ -494,7 +508,7 @@ class Terminal extends Plugin {
self._view.input.innerText = '\n'
if (script.length) {
self._cmdHistory.unshift(script)
self.commands.script(script)
self.commands.script(wrapScript(script))
}
self._components.autoCompletePopup.removeAutoComplete()
}

Loading…
Cancel
Save