File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import * as os from 'os';
88import { CliError } from './cli/cli-error' ;
99import { TELEMETRY_TRACKING_TOKEN } from './constants' ;
1010import isDocker from './utils/is-docker' ;
11+ import { isWsl } from './utils/is-wsl' ;
1112import { getMachineId } from './utils/machine-id-utils' ;
1213import { getVersion } from './utils/version-utils' ;
1314
@@ -42,6 +43,7 @@ export class Telemetry {
4243 private readonly version = getVersion ( ) ;
4344 private readonly prismaVersion = getPrismaVersion ( ) ;
4445 private readonly isDocker = isDocker ( ) ;
46+ private readonly isWsl = isWsl ( ) ;
4547 private exitWait = 200 ;
4648
4749 constructor ( ) {
@@ -105,6 +107,7 @@ export class Telemetry {
105107 version : this . version ,
106108 prismaVersion : this . prismaVersion ,
107109 isDocker : this . isDocker ,
110+ isWsl : this . isWsl ,
108111 ...properties ,
109112 } ;
110113 this . mixpanel . track ( event , payload ) ;
Original file line number Diff line number Diff line change 1+ import process from 'node:process' ;
2+ import os from 'node:os' ;
3+ import fs from 'node:fs' ;
4+ export const isWsl = ( ) => {
5+ if ( process . platform !== 'linux' ) {
6+ return false ;
7+ }
8+
9+ if ( os . release ( ) . toLowerCase ( ) . includes ( 'microsoft' ) ) {
10+ return true ;
11+ }
12+
13+ try {
14+ return fs . readFileSync ( '/proc/version' , 'utf8' ) . toLowerCase ( ) . includes ( 'microsoft' ) ;
15+ } catch {
16+ return false ;
17+ }
18+ } ;
You can’t perform that action at this time.
0 commit comments