-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #15 Linux AppImage/.deb file error finding binary in .resources…
… dir
- Loading branch information
Showing
4 changed files
with
76 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,64 @@ | ||
import path from "path"; | ||
import { remote } from "electron"; | ||
import getPlatform from "./get_platform"; | ||
import { getPlatform, NIX, MAC, WIN } from "./get_platform"; | ||
|
||
const IS_PROD = process.env.NODE_ENV === "production"; | ||
const root = process.cwd(); | ||
const { isPackaged, getAppPath } = remote.app; | ||
|
||
const binariesPath = | ||
IS_PROD && isPackaged | ||
? path.join(path.dirname(getAppPath()), "..", "./Resources", "./bin") | ||
: path.join(root, "./.resources", getPlatform(), "./bin"); | ||
function getDevBinariesPath() { | ||
path.join(root, "./.resources", getPlatform(), "./bin"); | ||
} | ||
|
||
const binFilename = getPlatform() === "win" ? "./exiftool.exe" : "./exiftool"; | ||
function getProdBinariesPath() { | ||
const platform = getPlatform(); | ||
|
||
console.log(`platform: ${platform}`); | ||
switch (platform) { | ||
case WIN: | ||
case MAC: | ||
return path.join( | ||
path.dirname(getAppPath()), | ||
"..", | ||
"./Resources", | ||
"./bin" | ||
); | ||
case NIX: | ||
return path.join( | ||
path.dirname(getAppPath()), | ||
"..", | ||
"./resources", | ||
"./bin" | ||
); | ||
default: | ||
throw `Could not determine the production binary path for ExifTool on platform ${platform}`; | ||
} | ||
} | ||
|
||
function getBinariesPath() { | ||
return IS_PROD && isPackaged ? getProdBinariesPath() : getDevBinariesPath(); | ||
} | ||
|
||
const binariesPath = getBinariesPath(); | ||
|
||
const BIN_FILENAME_WIN = "exiftool.exe"; | ||
const BIN_FILENAME_NIX_MAC = "exiftool"; | ||
|
||
function getBinFilename() { | ||
const platform = getPlatform(); | ||
|
||
switch (platform) { | ||
case WIN: | ||
return BIN_FILENAME_WIN; | ||
case NIX: | ||
case MAC: | ||
return BIN_FILENAME_NIX_MAC; | ||
default: | ||
throw `Could not determine the ExifTool binary path for platform ${platform}`; | ||
} | ||
} | ||
|
||
const binFilename = getBinFilename(); | ||
export const exiftoolBinPath = path.resolve( | ||
path.join(binariesPath, binFilename) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
import { platform } from "os"; | ||
|
||
export default () => { | ||
switch (platform()) { | ||
export const NIX = "nix"; | ||
export const MAC = "mac"; | ||
export const WIN = "win"; | ||
|
||
export function getPlatform() { | ||
const currentPlatform = platform(); | ||
|
||
switch (currentPlatform) { | ||
case "aix": | ||
case "freebsd": | ||
case "linux": | ||
case "openbsd": | ||
case "android": | ||
return "nix"; | ||
case "darwin": | ||
case "sunos": | ||
return "nix"; | ||
return NIX; | ||
case "darwin": | ||
return MAC; | ||
case "win32": | ||
return "win"; | ||
return WIN; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters