UNPKG

1.72 kBPlain TextView Raw
1#!/usr/bin/env node
2/**
3 * Wechaty Chatbot SDK - https://github.com/wechaty/wechaty
4 *
5 * @copyright 2016 Huan LI (李卓桓) <https://github.com/huan>, and
6 * Wechaty Contributors <https://github.com/wechaty>.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 */
21
22import os from 'os'
23
24import { config } from '../src/config'
25import { Doctor } from '../src/doctor'
26import { Wechaty } from '../src/wechaty'
27
28const wechaty = Wechaty.instance()
29const doctor = new Doctor()
30
31async function main () {
32 let ipcTestResult: string
33 try {
34 await doctor.testTcp()
35 ipcTestResult = 'PASS'
36 } catch (err) {
37 console.info(err)
38 ipcTestResult = 'FAIL. Please check your tcp network, Wechaty need to listen on localhost and connect to it.'
39 }
40
41 console.info(`
42 #### Wechaty Doctor
43
44 1. Wechaty version: ${wechaty.version()}
45 2. ${os.type()} ${os.arch()} version ${os.release()} memory ${Math.floor(os.freemem() / 1024 / 1024)}/${Math.floor(os.totalmem() / 1024 / 1024)} MB
46 3. Docker: ${config.docker}
47 4. Node version: ${process.version}
48 5. Tcp IPC TEST: ${ipcTestResult}
49
50 `)
51
52}
53
54main()
55 .catch(err => console.error('main() exception: %s', err))