Closed Nowaker closed 4 years ago
I'm not interested to create a PR.
Just an FYI then?
@JamieMason maybe a different logger level?
export const notinstalled = (value: string): void => {
console.log(color.red('!!! %s'), value);
process.exit(1);
};
Then change the warning()
calls in the runners, e.g.:
if (!(await pathExists(IMAGEOPTIM_BIN_PATH))) {
return notinstalled(`ImageOptim.app is not installed (${IMAGEOPTIM_URL})`);
}
Not sure if this means it would be caught by your exception handler, I don't think so... I think the Node process stops as soon as you call process.exit(1);
Seems a bit overkill for a rare scenario to me though.
Thanks @jamesstout, I think you're right that a new log level is the way to go – it seems better to throw than warn and it's easy for those who might not have been using --no-imageoptim
(that didn't have ImageOptim installed) and were ignoring the warnings to just add --no-imageoptim
to prevent the error and quit.
I think the Node process stops as soon as you call process.exit(1);
that's correct
that's correct
Thanks, so if bug()
calls process.exit(1);
, will this line ever run?
[not sure what await
does .. something something async promises?]
Thank you guys for looking into it!
I've just corrected the issue title. Not sure how it ended up like that.
Seems a bit overkill for a rare scenario to me though.
Not sure how rare it is but I used imageoptim
on Linux for years, and now when I'm on Mac I installed it using brew and thought it was working (seeing success messages and all that) but it actually did not.
[not sure what await does .. something something async promises?]
await
is a modern JS way to convert visually cluttered callbacks to code that looks iterative but still operates on callbacks. More on it here: https://blog.bitsrc.io/keep-your-promises-in-typescript-using-async-await-7bdc57041308
[not sure what await does .. something something async promises?]
that's right, it waits for the promise to resolve before continuing to the next line. Good thing you mentioned this as I'd missed the tearDown stuff, so I'll make sure that is always run.
Not sure how rare it is but I used
imageoptim
on Linux for years, and now when I'm on Mac I installed it using brew and thought it was working (seeing success messages and all that) but it actually did not.
Yes, apologies .. I was thinking only in macOS terms, and I agree, a correct return code is needed.
await is a modern JS way to convert visually cluttered callbacks to code that looks iterative but still operates on callbacks.
Thanks. I'm a JavaScript novice trying and failing to get this TypeScript project to build 😢
Good thing you mentioned this as I'd missed the tearDown stuff, so I'll make sure that is always run.
Definitely doesn't run clean()
(at the moment) when it exits on error:
I realised after releasing 😬 and started this change in a dev branch https://github.com/JamieMason/ImageOptim-CLI/commit/5a6b1d4f2977131b6b12b5ee33d51952b7caba81
Steps To Reproduce The Error
brew install imageoptim-cli
imageoptim
, the GUI appExpected Behaviour
Exit status 1, indicating a failure. The
! ImageOptim.app is not installed
line should be!!!
and red to indicate an error.Actual Behaviour
No error. Process exits with exit status 0, indicating a success. The
!
lines are yellow, indicating a warning, not error.Version Numbers or N/A
Help Needed
I'm not interested to create a PR.