index.js 426 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. const os = require('os');
  3. const fs = require('fs');
  4. const isWsl = () => {
  5. if (process.platform !== 'linux') {
  6. return false;
  7. }
  8. if (os.release().includes('Microsoft')) {
  9. return true;
  10. }
  11. try {
  12. return fs.readFileSync('/proc/version', 'utf8').includes('Microsoft');
  13. } catch (err) {
  14. return false;
  15. }
  16. };
  17. if (process.env.__IS_WSL_TEST__) {
  18. module.exports = isWsl;
  19. } else {
  20. module.exports = isWsl();
  21. }