fix: 🔧 修复 Linux 及 MacOS 获取默认依赖路径异常的问题

This commit is contained in:
viarotel 2023-10-20 21:56:27 +08:00
parent 45af64e07f
commit 87b533f714
4 changed files with 16 additions and 17 deletions

View File

@ -1,4 +1,5 @@
import { resolve } from 'node:path'
import which from 'which'
import { buildResolve, extraResolve } from '@electron/helpers/index.js'
@ -11,7 +12,14 @@ export const icoLogoPath = buildResolve('logo.ico')
export const icnsLogoPath = buildResolve('logo.icns')
export const adbPath
= process.platform === 'win32' ? extraResolve('core/adb.exe') : 'adb'
= process.platform === 'win32'
? extraResolve('core/adb.exe')
: which.sync('adb', { nothrow: true })
export const scrcpyPath
= process.platform === 'win32' ? extraResolve('core/scrcpy.exe') : 'scrcpy'
= process.platform === 'win32'
? extraResolve('core/scrcpy.exe')
: which.sync('scrcpy', { nothrow: true })
// console.log('adbPath', adbPath)
// console.log('scrcpyPath', scrcpyPath)

View File

@ -4,7 +4,6 @@ import path from 'node:path'
import fs from 'node:fs'
import dayjs from 'dayjs'
import { Adb } from '@devicefarmer/adbkit'
import _which from 'which'
import appStore from '@electron/helpers/store.js'
import { adbPath } from '@electron/configs/index.js'
@ -100,8 +99,6 @@ const install = async (id, path) => client.getDevice(id).install(path)
const version = async () => client.version()
const which = async () => _which('adb')
const watch = async (callback) => {
const tracker = await client.trackDevices()
tracker.on('add', async (ret) => {
@ -147,7 +144,6 @@ export default () => {
screencap,
install,
version,
which,
watch,
}
}

View File

@ -1,5 +1,4 @@
import { spawn } from 'node:child_process'
import _which from 'which'
import appStore from '@electron/helpers/store.js'
import { adbPath, scrcpyPath } from '@electron/configs/index.js'
@ -48,9 +47,6 @@ const shell = async (command, { stdout, stderr } = {}) => {
})
}
const which = async () => _which('scrcpy')
export default () => ({
shell,
which,
})

View File

@ -55,15 +55,14 @@ export default {
return false
}
try {
const adbWhichPath = await this.$adb.which()
console.log('adbWhichPath', adbWhichPath)
const scrcpyWhichPath = await this.$scrcpy.which()
console.log('scrcpyWhichPath', scrcpyWhichPath)
const { adbPath, scrcpyPath } = this.$electron?.configs || {}
if (adbPath) {
return false
}
catch (error) {
console.warn(error?.message || error?.cause?.message)
if (scrcpyPath) {
return false
}
this.$alert(