arch.js 723 B

12345678910111213141516171819202122232425262728293031
  1. 'use strict'
  2. const execSync = require('child_process').execSync
  3. module.exports = {
  4. host: function host (quiet) {
  5. const arch = process.arch
  6. if (arch === 'arm') {
  7. switch (process.config.variables.arm_version) {
  8. case '6':
  9. return module.exports.uname()
  10. case '7':
  11. return 'armv7l'
  12. default:
  13. if (!quiet) {
  14. console.warn(`WARNING: Could not determine specific ARM arch. Detected ARM version: ${JSON.stringify(process.config.variables.arm_version)}`)
  15. }
  16. }
  17. }
  18. return arch
  19. },
  20. /**
  21. * Returns the arch name from the `uname` utility.
  22. */
  23. uname: function uname () {
  24. return execSync('uname -m').toString().trim()
  25. }
  26. }