1 | import process from 'node:process';
|
2 | import os from 'node:os';
|
3 | import fs from 'node:fs';
|
4 | import isInsideContainer from 'is-inside-container';
|
5 |
|
6 | const isWsl = () => {
|
7 | if (process.platform !== 'linux') {
|
8 | return false;
|
9 | }
|
10 |
|
11 | if (os.release().toLowerCase().includes('microsoft')) {
|
12 | if (isInsideContainer()) {
|
13 | return false;
|
14 | }
|
15 |
|
16 | return true;
|
17 | }
|
18 |
|
19 | try {
|
20 | return fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft')
|
21 | ? !isInsideContainer() : false;
|
22 | } catch {
|
23 | return false;
|
24 | }
|
25 | };
|
26 |
|
27 | export default process.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|