JamieMason / ImageOptim-CLI

Make optimisation of images part of your automated build process
https://foldleft.io/image-tools
MIT License
3.46k stars 126 forks source link

Wrong path used to launch AppleScript scripts #163

Closed nicolinuxfr closed 6 years ago

nicolinuxfr commented 6 years ago

Types of Changes

What types of changes does your issue require? Put an x in all the boxes that apply:

Description

After installing the latest version of ImageOptim using npm, I have the following error when I try to activate JPEG mini :

! Command failed: osascript /Users/nicolas/osascript/is-installed.applescript com.icvt.JPEGmini-Pro
osascript: /Users/nicolas/osascript/is-installed.applescript: No such file or directory

! Please raise an issue at https://github.com/JamieMason/ImageOptim-CLI/issues

    Error: Command failed: osascript /Users/nicolas/osascript/is-installed.applescript com.icvt.JPEGmini-Pro
    osascript: /Users/nicolas/osascript/is-installed.applescript: No such file or directory

        at makeError (/usr/local/lib/node_modules/imageoptim-cli/dist/imageoptim:10024:9)
        at Promise.all.then.arr (/usr/local/lib/node_modules/imageoptim-cli/dist/imageoptim:10129:16)
        at process._tickCallback (internal/process/next_tick.js:178:7)

I checked, and indeed, I have no osascripts folder inside my home folder.

Setup

macOS High Sierra 10.13.4
npm 5.10.0
node 10.1.0
JPEGmini standard 2.2.1

JamieMason commented 6 years ago

Thanks @nicolinuxfr, am I right that you've followed the manual installation? This is an oversight on my part because the osascript directory is needed as well as the binary. Could you confirm though incase I'm on the wrong track? Thanks a lot.

nicolinuxfr commented 6 years ago

Nope, I used the recommended way : npm install -g imageoptim-cli

I tried with and without sudo, for information.

JamieMason commented 6 years ago

oh...oh dear 😄 I am on a different machine now to the one I developed the new version in so I will install it here and see if I can reproduce it.

JamieMason commented 6 years ago

this is the problem line https://github.com/JamieMason/ImageOptim-CLI/blob/3faa790f9088e5988eccb897a67111dd54d4f57d/src/applescript.ts#L14

I think using https://github.com/nexe/nexe to create a self contained executable is causing __dirname to not behave in the way I would expect. I'll get this fixed urgently.

nicolinuxfr commented 6 years ago

Great news if you can fix it easily. :-)

JamieMason commented 6 years ago

I seem to have it working locally, will release soon.

JamieMason commented 6 years ago

Please give 2.0.2 a try and reopen if there are still issues, thanks.

nicolinuxfr commented 6 years ago

Works great with 2.0.2, thanks for the quick fix ! 👍

JamieMason commented 6 years ago

you're welcome Nicolas, it was a big one so it needed sorting ASAP 😄