Files
vue-cli/packages/@vue/cli-ui/apollo-server/util/terminate.js
Haoqun Jiang 0f377bd31d feat: upgrade to eslint 6 (#4933)
* feat: scaffold projects with eslint 6

* style: eslint fix

* refactor: do not use hard-coded ecmaVersion, use babel-eslint for now

* fix: upgrade to @vue/eslint-config-standard

* style: continue fix lint errors

* chore: upgrade to eslint-plugin-vue@^6.1.2

* refactor: use `ecmaVersion: 2020` for dynamic import syntax support

* test: fix baseESLintConfig

* chore: also update yarn.lock to fix CI caches

* chore: update lockfile again, fix babel regressions

* test: nightwatch tests should fail if lint errors occur

* chore: update the lockfile (again), fixing a bug in airbnb config
2020-01-14 10:13:54 +08:00

43 lines
1.0 KiB
JavaScript

const util = require('util')
const cp = require('child_process')
const path = require('path')
const {
isWindows,
isLinux,
isMacintosh
} = require('@vue/cli-shared-utils')
const execFile = util.promisify(cp.execFile)
const spawn = util.promisify(cp.spawn)
exports.terminate = async function (childProcess, cwd) {
if (isWindows) {
try {
const options = {
stdio: ['pipe', 'pipe', 'ignore']
}
if (cwd) {
options.cwd = cwd
}
await execFile('taskkill', ['/T', '/F', '/PID', childProcess.pid.toString()], options)
} catch (err) {
return { success: false, error: err }
}
} else if (isLinux || isMacintosh) {
try {
const cmd = path.resolve(__dirname, './terminate.sh')
const result = await spawn(cmd, [childProcess.pid.toString()], {
cwd
})
if (result.error) {
return { success: false, error: result.error }
}
} catch (err) {
return { success: false, error: err }
}
} else {
childProcess.kill('SIGKILL')
}
return { success: true }
}