Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Commit

Permalink
Detached cmds fix disabled + add cwd, fix kill, fix stop-cmd, update …
Browse files Browse the repository at this point in the history
…packages
  • Loading branch information
Dewep committed Apr 28, 2018
1 parent e9b3efa commit fd67553
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 215 deletions.
21 changes: 16 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const fs = require('fs')
const path = require('path')
const childProcess = require('child_process')
const electron = require('electron')
const treeKill = require('tree-kill')

const configFile = path.join(electron.remote.app.getPath('home'), 'gce.yml')
let config = {}
Expand Down Expand Up @@ -108,6 +109,9 @@ window.app = new Vue({
if (!Array.isArray(cmd.cmd)) {
cmd.cmd = cmd.cmd.split(' ')
}
if (cmd['stop-cmd'] && !Array.isArray(cmd['stop-cmd'])) {
cmd['stop-cmd'] = cmd['stop-cmd'].split(' ')
}

cmd.extra = getExtras(cmd.extra)

Expand Down Expand Up @@ -233,11 +237,17 @@ window.app = new Vue({
if (this.status[cmd.slug] === 1 && cmd.proc) {
this.addContent(cmd, 'info', 'Killing the process...')
cmd.stop = true
if (process.platform === 'win32') {
childProcess.exec('taskkill -F -T -PID ' + cmd.proc.pid)
} else {
cmd.proc.kill('SIGINT')
}
treeKill(cmd.proc.pid, err => {
if (err) {
this.addContent(cmd, 'info', 'Error during killing the process')
this.addContent(cmd, 'info', err.message)
}
})
// if (process.platform === 'win32') {
// childProcess.exec('taskkill -F -T -PID ' + cmd.proc.pid)
// } else {
// cmd.proc.kill('SIGINT')
// }
return true
}
return false
Expand Down Expand Up @@ -269,6 +279,7 @@ window.app = new Vue({
const cwd = this.getCWD(cmd)
const argv = subcmd.map(arg => arg.replace('%dir%', cwd))
const subprocess = childProcess.spawn(argv[0], argv.slice(1), {
cwd,
detached: true,
stdio: 'ignore'
})
Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@
</div>
</div>
<ul id="status-bar" v-show="menu" style="display: none">
<li class="version">GCE 1.2.0</li>
<li class="version">GCE 1.2.1</li>
<template v-if="active && active.slug">
<li>
<a @click="clear(active)" :class="{ disabled: !content[active.slug] || !content[active.slug].length }">Clear</a>
</li>
<li v-for="(extra, $index) in active.extra" :key="'extra-' + active.slug + '-' + $index">
<a @click="runSubCommand(extra)" :class="{ disabled: status[active.slug] !== 0 && status[active.slug] !== 3 }">{{ extra.name || extra.cmd || extra }}</a>
<a @click="runSubCommand(extra)" :class="{ disabled: !extra.detached && status[active.slug] !== 0 && status[active.slug] !== 3 }">{{ extra.name || extra.cmd || extra }}</a>
</li>
</template>
<li v-if="active && active.url">
Expand Down
Loading

0 comments on commit fd67553

Please sign in to comment.