Skip to content

Commit

Permalink
fix: /usr/bin/file can return errors on MacOS; ignore these errors (#13)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Plotkin <[email protected]>
  • Loading branch information
erkyrath and Andrew Plotkin committed May 9, 2021
1 parent d9b1b41 commit e7d57dd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/file-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spawn } from '@malept/cross-spawn-promise';
import { spawn, ExitCodeError } from '@malept/cross-spawn-promise';
import * as fs from 'fs-extra';
import * as path from 'path';

Expand Down Expand Up @@ -34,7 +34,16 @@ export const getAllAppFiles = async (appPath: string): Promise<AppFile[]> => {
if (info.isFile()) {
let fileType = AppFileType.PLAIN;

const fileOutput = await spawn('file', ['--brief', '--no-pad', p]);
var fileOutput = '';
try {
fileOutput = await spawn('file', ['--brief', '--no-pad', p]);
} catch (e) {
if (e instanceof ExitCodeError) {
/* silently accept error codes from "file" */
} else {
throw e;
}
}
if (p.includes('app.asar')) {
fileType = AppFileType.APP_CODE;
} else if (fileOutput.startsWith(MACHO_PREFIX)) {
Expand Down

0 comments on commit e7d57dd

Please sign in to comment.