File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import fs from 'fs'
22import path from 'path'
33import plist from 'plist'
44import { Adapter } from './adapter'
5- import { readdirSafe , readFileSafe } from './utils'
5+ import { readdirSafe , readFileSafe , readFileAsBufferSafe } from './utils'
66
77export class MacosAdapter extends Adapter {
88 async readApps ( ) {
@@ -40,7 +40,9 @@ export class MacosAdapter extends Adapter {
4040 }
4141
4242 private async readIcnsAsImageUri ( file : string ) {
43- let buf = await fs . promises . readFile ( file )
43+ let buf = await readFileAsBufferSafe ( file )
44+ if ( ! buf ) return ''
45+
4446 const totalSize = buf . readInt32BE ( 4 ) - 8
4547 buf = buf . slice ( 8 )
4648
Original file line number Diff line number Diff line change @@ -17,3 +17,12 @@ export async function readFileSafe(p: string) {
1717 return ''
1818 }
1919}
20+
21+ export async function readFileAsBufferSafe ( p : string ) {
22+ try {
23+ return await fs . promises . readFile ( p )
24+ } catch ( err ) {
25+ console . error ( err )
26+ return
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments