platform.js 708 B

123456789101112131415161718192021222324
  1. 'use strict';
  2. const detectLibc = require('detect-libc');
  3. const env = process.env;
  4. module.exports = function () {
  5. const arch = env.npm_config_arch || process.arch;
  6. const platform = env.npm_config_platform || process.platform;
  7. /* istanbul ignore next */
  8. const libc = (platform === 'linux' && detectLibc.isNonGlibcLinux) ? detectLibc.family : '';
  9. const platformId = [`${platform}${libc}`];
  10. if (arch === 'arm') {
  11. platformId.push(`armv${env.npm_config_arm_version || process.config.variables.arm_version || '6'}`);
  12. } else if (arch === 'arm64') {
  13. platformId.push(`arm64v${env.npm_config_arm_version || '8'}`);
  14. } else {
  15. platformId.push(arch);
  16. }
  17. return platformId.join('-');
  18. };