Commit 5c49808f authored by yann300's avatar yann300

change emitting event

parent 40484a34
...@@ -104,11 +104,11 @@ class Terminal extends Plugin { ...@@ -104,11 +104,11 @@ class Terminal extends Plugin {
this.on('scriptRunner', 'error', (msg) => { this.on('scriptRunner', 'error', (msg) => {
this.commands.error.apply(this.commands, msg.data) this.commands.error.apply(this.commands, msg.data)
}) })
this.on('git', 'log', (result) => { this.on('git', 'log', (result) => {
this.commands.html.apply(this.commands, yo`<pre>${result}</pre>`) this.commands.html(yo`<pre>${result}</pre>`)
}) })
this.on('git', 'error', (result) => { 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 { ...@@ -493,7 +493,7 @@ class Terminal extends Plugin {
return self._view.el return self._view.el
function wrapScript (script) { 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 if (isKnownScript) return script
return ` return `
try { try {
...@@ -755,7 +755,7 @@ class Terminal extends Plugin { ...@@ -755,7 +755,7 @@ class Terminal extends Plugin {
} }
} }
try { try {
if (script.trim().startWith('git')) { if (script.trim().startsWith('git')) {
await this.call('git', 'execute', script) await this.call('git', 'execute', script)
} else { } else {
await this.call('scriptRunner', 'execute', script) await this.call('scriptRunner', 'execute', script)
......
...@@ -21,16 +21,17 @@ export class GitClient extends PluginClient { ...@@ -21,16 +21,17 @@ export class GitClient extends PluginClient {
assertCommand(cmd) assertCommand(cmd)
const options = { cwd: this.currentSharedFolder, shell: true } const options = { cwd: this.currentSharedFolder, shell: true }
const child = spawn(cmd, options) const child = spawn(cmd, options)
let result = ''
let error = ''
child.stdout.on('data', (data) => { child.stdout.on('data', (data) => {
this.emit('log', data.toString()) result += data.toString()
}) })
child.stderr.on('data', (err) => { child.stderr.on('data', (err) => {
this.emit('error', err.toString()) error += err.toString()
}) })
child.on('close', (exitCode) => { child.on('close', () => {
if (exitCode !== 0) { if (error !== '') this.emit('error', error)
this.emit('error', 'exit with ' + exitCode) else this.emit('log', result)
}
}) })
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment