| 123456789101112131415161718192021222324252627282930 |
- #!/usr/bin/env node
- const { execSync } = require('child_process')
- const path = require('path')
- // 从配置文件读取 ADB 路径
- const config = require(path.join(__dirname, '..', '..', 'configs', 'config.js'))
- const projectRoot = path.resolve(__dirname, '..', '..')
- const adbPath = config.adbPath?.path
- ? path.resolve(projectRoot, config.adbPath.path)
- : path.join(projectRoot, 'lib', 'scrcpy-adb', 'adb.exe')
- const deviceIp = process.argv[2]
- const devicePort = process.argv[3] || '5555'
- if (!deviceIp) {
- process.exit(1)
- }
- const deviceId = `${deviceIp}:${devicePort}`
- const devicesCommand = `"${adbPath}" devices`
- const devicesOutput = execSync(devicesCommand, { encoding: 'utf-8', timeout: 1000 })
- const isConnected = devicesOutput.includes(deviceId) && devicesOutput.includes('device')
- if (isConnected) {
- process.exit(0)
- }
- else
- {
- process.exit(1)
- }
|