Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix crash at installation on linux platforms with non-intel archs #126

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ import bin from './index.js';

(async () => {
try {
// On linux platforms with non-intel architectures, bin-wrapper still
// downloads and tries to execute the x86_64 ELF. This results in the
// binary file being interpreted as a shell script, which creates a
// dangling file that can make npm or yarn crash at installation. This
// condition prevents this from happening.
//
// See https://github.com/imagemin/gifsicle-bin/issues/124#issuecomment-1222646680
if (process.platform === 'linux' && !['ia32', 'x64'].includes(process.arch)) {
throw Error(`Unsupported platform: ${process.platform}/${process.arch}.`);
}

await bin.run(['--version']);
console.log('optipng pre-build test passed successfully');
} catch (error) {
Expand Down