Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Add a platform variant for installing a musl binary #1836

Merged
merged 15 commits into from
Dec 18, 2016
12 changes: 8 additions & 4 deletions lib/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,14 @@ function getPlatformVariant() {
if (process.platform !== 'linux') {
return '';
}
if (fs.readFileSync(process.execPath).indexOf('libc.musl-x86_64.so.1') !== -1) {
return 'musl';
}
return '';
var contents = '';
try {
contents = fs.readFileSync('foo.bar').toString();
if (contents.indexOf('libc.musl-x86_64.so.1') !== -1) {
Copy link

@S-YOU S-YOU Dec 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I sent comment while you are updating this.
toString is slow on where Buffer.indexOf is available. so this would be longer version.

contents = fs.readFileSync('foo.bar');
if (!contents.indexOf) {
  contents = contents.toString();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starts to get a bit micro-optimization-y for my tastes, but sure.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @ncopa can you confirm it's ok to cover all Alpine releases or should we look for a wider pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you asking whether this test will work for all Alpine releases? If so, yes.

return 'musl';
}
} catch (err) { }
return ''
}

module.exports.hasBinary = hasBinary;
Expand Down