index.js 723 B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. var os = require('os');
  3. var osxRelease = require('osx-release');
  4. var winRelease = require('win-release');
  5. module.exports = function (platform, release) {
  6. if (!platform && release) {
  7. throw new Error('You can\'t specify a `release` without specfying `platform`');
  8. }
  9. platform = platform || os.platform();
  10. release = release || os.release();
  11. var id;
  12. if (platform === 'darwin') {
  13. id = osxRelease(release).name;
  14. return 'OS X' + (id ? ' ' + id : '');
  15. }
  16. if (platform === 'linux') {
  17. id = release.replace(/^(\d+\.\d+).*/, '$1');
  18. return 'Linux' + (id ? ' ' + id : '');
  19. }
  20. if (platform === 'win32') {
  21. id = winRelease(release);
  22. return 'Windows' + (id ? ' ' + id : '');
  23. }
  24. return platform;
  25. };