Skip to content

Commit

Permalink
Fixed #15 Linux AppImage/.deb file error finding binary in .resources…
Browse files Browse the repository at this point in the history
… dir
  • Loading branch information
szTheory committed Apr 26, 2020
1 parent 1c48094 commit 76ebf49
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 75 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ $ cd exifcleaner
Next, install the NPM package dependencies.

```bash
$ npm install
$ yarn install
```

Finally, launch the application. This supports Hot Module Reload (HMR) so you will automatically see your changes every time you save a file.

```bash
$ npm run dev
$ yarn run dev
```

### Contributing
Expand All @@ -141,8 +141,8 @@ This app is mostly feature complete. I want to keep it simple and not add a bunc
This section is really for my own reference when publishing a new release.

```
$ npm run release
$ npm run dist
$ yarn run release
$ yarn run dist
```

Or instead of `npm run dist`, after Travis finishes building your app, open the release draft it created and click "Publish".
Or instead of `yarn run dist`, after Travis finishes building your app, open the release draft it created and click "Publish".
59 changes: 53 additions & 6 deletions src/common/binaries.js
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)
);
20 changes: 13 additions & 7 deletions src/common/get_platform.js
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;
}
};
}
62 changes: 5 additions & 57 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -786,11 +786,6 @@
resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.2.tgz#690a1475b84f2a884fd07cd797c00f5f31356ea8"
integrity sha512-ce5d3q03Ex0sy4R14722Rmt6MT07Ua+k4FwDfdcToYJcMKNtRVQvJ6JCAPdAmAnbRb6CsX6aYb9m96NGod9uTw==

"@types/semver@^6.0.2":
version "6.2.0"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-6.2.0.tgz#d688d574400d96c5b0114968705366f431831e1a"
integrity sha512-1OzrNb4RuAzIT7wHSsgZRlMBlNsJl+do6UblR7JMW4oB7bbR+uBEYtUh7gEc/jM84GGilh68lSOokyM/zNUlBA==

"@types/webpack-env@^1.13.9":
version "1.14.1"
resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.14.1.tgz#0d8a53f308f017c53a5ddc3d07f4d6fa76b790d7"
Expand Down Expand Up @@ -1653,14 +1648,6 @@ builder-util-runtime@8.3.0:
debug "^4.1.1"
sax "^1.2.4"

builder-util-runtime@8.4.0:
version "8.4.0"
resolved "https://registry.yarnpkg.com/builder-util-runtime/-/builder-util-runtime-8.4.0.tgz#3163fffc078e6b8f3dd5b6eb12a8345573590682"
integrity sha512-CJB/eKfPf2vHrkmirF5eicVnbDCkMBbwd5tRYlTlgud16zFeqD7QmrVUAOEXdnsrcNkiLg9dbuUsQKtl/AwsYQ==
dependencies:
debug "^4.1.1"
sax "^1.2.4"

builder-util-runtime@8.5.0:
version "8.5.0"
resolved "https://registry.yarnpkg.com/builder-util-runtime/-/builder-util-runtime-8.5.0.tgz#0c9faa782307867cc2ec70f25e63829ef1ea49c4"
Expand Down Expand Up @@ -2853,16 +2840,6 @@ dir-glob@^2.2.2:
dependencies:
path-type "^3.0.0"

dist-exiftool@^10.53.0:
version "10.53.0"
resolved "https://registry.yarnpkg.com/dist-exiftool/-/dist-exiftool-10.53.0.tgz#8bd17bac1e43deacd81d9adacd0f1e24c690100f"
integrity sha1-i9F7rB5D3qzYHZrazQ8eJMaQEA8=
dependencies:
platform-dependent-modules "0.0.14"
optionalDependencies:
exiftool.exe "10.53"
exiftool.pl "10.53"

dmg-builder@21.2.0:
version "21.2.0"
resolved "https://registry.yarnpkg.com/dmg-builder/-/dmg-builder-21.2.0.tgz#a9c883557cacb9abdb66c7133b30fe921c1a3ba7"
Expand Down Expand Up @@ -3155,20 +3132,6 @@ electron-unhandled@^3.0.0:
ensure-error "^2.0.0"
lodash.debounce "^4.0.8"

electron-updater@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/electron-updater/-/electron-updater-4.2.0.tgz#f9ecfc657f65ead737d42b9efecf628d3756b550"
integrity sha512-GuS3g7HDh17x/SaFjxjswlWUaKHczksYkV2Xc5CKj/bZH0YCvTSHtOmnBAdAmCk99u/71p3zP8f0jIqDfGcjww==
dependencies:
"@types/semver" "^6.0.2"
builder-util-runtime "8.4.0"
fs-extra "^8.1.0"
js-yaml "^3.13.1"
lazy-val "^1.0.4"
lodash.isequal "^4.5.0"
pako "^1.0.10"
semver "^6.3.0"

electron-util@^0.13.0:
version "0.13.0"
resolved "https://registry.yarnpkg.com/electron-util/-/electron-util-0.13.0.tgz#bce9032ab07cab3bc3448451f2a48a766ef51cce"
Expand Down Expand Up @@ -3755,16 +3718,6 @@ execa@^3.4.0:
signal-exit "^3.0.2"
strip-final-newline "^2.0.0"

exiftool.exe@10.53:
version "10.53.0"
resolved "https://registry.yarnpkg.com/exiftool.exe/-/exiftool.exe-10.53.0.tgz#22b1ce60fb8db589469d1aa5b0a1fe09a35bc454"
integrity sha1-IrHOYPuNtYlGnRqlsKH+CaNbxFQ=

exiftool.pl@10.53:
version "10.53.0"
resolved "https://registry.yarnpkg.com/exiftool.pl/-/exiftool.pl-10.53.0.tgz#63c1646b3ad0aed1ce1313d7b5d07da4d7b13d84"
integrity sha1-Y8FkazrQrtHOExPXtdB9pNexPYQ=

expand-brackets@^2.1.4:
version "2.1.4"
resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622"
Expand Down Expand Up @@ -6507,10 +6460,10 @@ node-releases@^1.1.42:
dependencies:
semver "^6.3.0"

node-sass@^4.13.0:
version "4.13.0"
resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.13.0.tgz#b647288babdd6a1cb726de4545516b31f90da066"
integrity sha512-W1XBrvoJ1dy7VsvTAS5q1V45lREbTlZQqFbiHb3R3OTTCma0XBtuG6xZ6Z4506nR4lmHPTqVRwxT6KgtWC97CA==
node-sass@^4.13.1:
version "4.14.0"
resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.14.0.tgz#a8e9d7720f8e15b4a1072719dcf04006f5648eeb"
integrity sha512-AxqU+DFpk0lEz95sI6jO0hU0Rwyw7BXVEv6o9OItoXLyeygPeaSpiV4rwQb10JiTghHaa0gZeD21sz+OsQluaw==
dependencies:
async-foreach "^0.1.3"
chalk "^1.1.1"
Expand Down Expand Up @@ -7022,7 +6975,7 @@ package-json@^6.3.0:
registry-url "^5.0.0"
semver "^6.2.0"

pako@^1.0.10, pako@~1.0.5:
pako@~1.0.5:
version "1.0.10"
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.10.tgz#4328badb5086a426aa90f541977d4955da5c9732"
integrity sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw==
Expand Down Expand Up @@ -7266,11 +7219,6 @@ pkg-up@^3.0.1:
dependencies:
find-up "^3.0.0"

platform-dependent-modules@0.0.14:
version "0.0.14"
resolved "https://registry.yarnpkg.com/platform-dependent-modules/-/platform-dependent-modules-0.0.14.tgz#3c53d0415d81ce22dcfde15665d0cfd541d41617"
integrity sha1-PFPQQV2BziLc/eFWZdDP1UHUFhc=

plur@^3.0.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/plur/-/plur-3.1.1.tgz#60267967866a8d811504fe58f2faaba237546a5b"
Expand Down

0 comments on commit 76ebf49

Please sign in to comment.