Skip to content

Commit

Permalink
fix: installed apps not found
Browse files Browse the repository at this point in the history
  • Loading branch information
will-stone committed Nov 23, 2022
1 parent 0cd62b3 commit db0f9c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 31 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 8 additions & 30 deletions src/main/utils/get-installed-app-ids.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { execFile } from 'node:child_process'
import { homedir } from 'node:os'
import path from 'node:path'
import { promisify } from 'node:util'
import { execSync } from 'node:child_process'

import { sleep } from 'tings'

Expand All @@ -10,40 +7,21 @@ import { apps } from '../../config/apps'
import { retrievedInstalledApps, startedScanning } from '../state/actions'
import { dispatch } from '../state/store'

const execFileP = promisify(execFile)

async function getAllInstalledBundleIds(): Promise<string[]> {
const { stdout: allApps } = await execFileP('mdfind', [
"kMDItemKind == 'Application'",
'-onlyin',
'/Applications',
'-onlyin',
path.join(homedir(), 'Applications'),
])

const bundleIds = await Promise.all(
allApps
.trim()
.split('\n')
.map(async (entry) => {
const { stdout: bundleId } = await execFileP('mdls', [
'-name',
'kMDItemCFBundleIdentifier',
'-raw',
entry,
])

return bundleId
}),
function getAllInstalledBundleIds(): string[] {
const bundleIds = execSync(
'mdfind -onlyin /Applications kMDItemKind == \'*\' -attr kMDItemCFBundleIdentifier | sed -e "s/^.*kMDItemCFBundleIdentifier = //" -e "/(null)/d"',
)
.toString()
.trim()
.split('\n')

return bundleIds
}

async function getInstalledAppIds(): Promise<void> {
dispatch(startedScanning())

const allInstalledBundleIds = await getAllInstalledBundleIds()
const allInstalledBundleIds = getAllInstalledBundleIds()
const installedApps: AppId[] = []

for (const installedBundleId of allInstalledBundleIds) {
Expand Down

0 comments on commit db0f9c7

Please sign in to comment.