diff --git a/apps/remix-ide/src/app/panels/terminal.js b/apps/remix-ide/src/app/panels/terminal.js index 899aef827f..6d22078d65 100644 --- a/apps/remix-ide/src/app/panels/terminal.js +++ b/apps/remix-ide/src/app/panels/terminal.js @@ -103,13 +103,7 @@ 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(yo`
${result}
`) - }) - this.on('git', 'error', (result) => { - this.commands.html(yo`
${result}
`) - }) + }) } onDeactivation () { @@ -117,8 +111,6 @@ class Terminal extends Plugin { this.off('scriptRunner', 'info') this.off('scriptRunner', 'warn') this.off('scriptRunner', 'error') - this.off('git', 'log') - this.off('git', 'error') } logHtml (html) { @@ -755,11 +747,13 @@ class Terminal extends Plugin { } } try { + let result if (script.trim().startsWith('git')) { - await this.call('git', 'execute', script) + result = await this.call('git', 'execute', script) } else { - await this.call('scriptRunner', 'execute', script) + result = await this.call('scriptRunner', 'execute', script) } + if (result) self.commands.html(yo`
${result}
`) done() } catch (error) { done(error.message || error) diff --git a/libs/remixd/src/services/gitClient.ts b/libs/remixd/src/services/gitClient.ts index 2c57b845b8..58949669d4 100644 --- a/libs/remixd/src/services/gitClient.ts +++ b/libs/remixd/src/services/gitClient.ts @@ -17,22 +17,24 @@ export class GitClient extends PluginClient { this.readOnly = readOnly } - execute (cmd: string) { - assertCommand(cmd) - const options = { cwd: this.currentSharedFolder, shell: true } - const child = spawn(cmd, options) - let result = '' - let error = '' - child.stdout.on('data', (data) => { - result += data.toString() - }) - child.stderr.on('data', (err) => { - error += err.toString() - }) - child.on('close', () => { - if (error !== '') this.emit('error', error) - else this.emit('log', result) - }) + execute (cmd: string) { + assertCommand(cmd) + const options = { cwd: this.currentSharedFolder, shell: true } + const child = spawn(cmd, options) + let result = '' + let error = '' + return new Promise((resolve, reject) => { + child.stdout.on('data', (data) => { + result += data.toString() + }) + child.stderr.on('data', (err) => { + error += err.toString() + }) + child.on('close', () => { + if (error) reject(error) + else resolve(result) + }) + }) } }