change emitting event

pull/638/head
yann300 4 years ago
parent 40484a34a3
commit 5c49808fba
  1. 10
      apps/remix-ide/src/app/panels/terminal.js
  2. 13
      libs/remixd/src/services/gitClient.ts

@ -104,11 +104,11 @@ class Terminal extends Plugin {
this.on('scriptRunner', 'error', (msg) => {
this.commands.error.apply(this.commands, msg.data)
})
this.on('git', 'log', (result) => {
this.commands.html.apply(this.commands, yo`<pre>${result}</pre>`)
this.on('git', 'log', (result) => {
this.commands.html(yo`<pre>${result}</pre>`)
})
this.on('git', 'error', (result) => {
this.commands.html.apply(this.commands, yo`<pre>${result}</pre>`)
this.commands.html(yo`<pre>${result}</pre>`)
})
}
@ -493,7 +493,7 @@ class Terminal extends Plugin {
return self._view.el
function wrapScript (script) {
const isKnownScript = ['remix.', 'git'].some(prefix => script.trim().startWith(prefix))
const isKnownScript = ['remix.', 'git'].some(prefix => script.trim().startsWith(prefix))
if (isKnownScript) return script
return `
try {
@ -755,7 +755,7 @@ class Terminal extends Plugin {
}
}
try {
if (script.trim().startWith('git')) {
if (script.trim().startsWith('git')) {
await this.call('git', 'execute', script)
} else {
await this.call('scriptRunner', 'execute', script)

@ -21,16 +21,17 @@ export class GitClient extends PluginClient {
assertCommand(cmd)
const options = { cwd: this.currentSharedFolder, shell: true }
const child = spawn(cmd, options)
let result = ''
let error = ''
child.stdout.on('data', (data) => {
this.emit('log', data.toString())
result += data.toString()
})
child.stderr.on('data', (err) => {
this.emit('error', err.toString())
error += err.toString()
})
child.on('close', (exitCode) => {
if (exitCode !== 0) {
this.emit('error', 'exit with ' + exitCode)
}
child.on('close', () => {
if (error !== '') this.emit('error', error)
else this.emit('log', result)
})
}
}

Loading…
Cancel
Save