diff --git a/lib/install.js b/lib/install.js index 764e30f..1453f79 100644 --- a/lib/install.js +++ b/lib/install.js @@ -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('gifsicle pre-build test passed successfully'); } catch (error) {