提交 93784890 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

code clean

上级 0a67b745
#!/usr/bin/env ts-node
import * as os from 'os'
import {
Config
, Wechaty
} from '../'
import * as os from 'os'
const wechaty = Wechaty.instance()
......
......@@ -4,30 +4,14 @@
#
# https://github.com/wechaty/wechaty
#
# Original Code Credit: https://github.com/cusspvz/node.docker/blob/master/entrypoint
#
set -e
echo
echo "Starting Wechaty v$(wechaty-version) ..."
echo
# to identify run env (for tests)
# @deprecated 20161001, use cgroup to test
# export WECHATY_DOCKER='docker'
# set CI here, in order to force ava to output use --verbose param, which is fit docker console log
export CI="FORCE_AVA_OUTPUT_VERBOSE"
# [ "$WECHATY_HEAD" != "" ] && {
# echo "WECHATY_HEAD=$WECHATY_HEAD"
# }
# if [ "$WECHATY_HEAD" != "phantomjs" ]; then
# export DISPLAY=':99.0'
# Xvfb :99 -ac -screen 0 640x480x8 -nolisten tcp &
# echo "Xvfb started on DISPLAY=$DISPLAY"
# fi
# export CI="FORCE_AVA_OUTPUT_VERBOSE"
if [ "$1" = "start" ]; then
exec npm start
......
......@@ -6,4 +6,4 @@ test:
override:
- docker info
- docker build -t zixia/wechaty:test .
- docker run -v /dev/shm:/dev/shm zixia/wechaty:test test
- docker run --rm -v /dev/shm:/dev/shm zixia/wechaty:test test
......@@ -222,7 +222,7 @@ export class Browser extends EventEmitter {
public getBrowserPids(): Promise<string[]> {
log.silly('PuppetWebBrowser', 'getBrowserPids()')
const head = this.setting.head as string
const head = this.setting.head
return new Promise((resolve, reject) => {
require('ps-tree')(process.pid, (err, children) => {
......@@ -232,21 +232,19 @@ export class Browser extends EventEmitter {
}
let browserRe
switch (true) {
case !head: // no head default to phantomjs
case /phantomjs/i.test(head):
case /phantom/i.test(head):
switch (head) {
case 'phantomjs':
browserRe = 'phantomjs'
break
case !!(head): // head default to chrome
case /chrome/i.test(head):
case 'chrome':
browserRe = 'chrome(?!driver)|chromium'
break
default:
log.warn('PuppetWebBrowser', 'getBrowserPids() for unsupported head: %s', head)
browserRe = head
const e = new Error('unsupported head: ' + head)
log.warn('PuppetWebBrowser', 'getBrowserPids() for %s', e.message)
throw e
}
let matchRegex = new RegExp(browserRe, 'i')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册