aswi2020vldc-gitlab/templetes/node_modules/is-wsl/index.js @ 9bb1e829
1 |
'use strict'; |
---|---|
2 |
const os = require('os'); |
3 |
const fs = require('fs'); |
4 |
|
5 |
const isWsl = () => { |
6 |
if (process.platform !== 'linux') { |
7 |
return false; |
8 |
}
|
9 |
|
10 |
if (os.release().includes('Microsoft')) { |
11 |
return true; |
12 |
}
|
13 |
|
14 |
try { |
15 |
return fs.readFileSync('/proc/version', 'utf8').includes('Microsoft'); |
16 |
} catch (err) { |
17 |
return false; |
18 |
}
|
19 |
};
|
20 |
|
21 |
if (process.env.__IS_WSL_TEST__) { |
22 |
module.exports = isWsl; |
23 |
} else { |
24 |
module.exports = isWsl(); |
25 |
}
|