File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ import isDocker from './utils/is-docker';
11
11
import { isWsl } from './utils/is-wsl' ;
12
12
import { getMachineId } from './utils/machine-id-utils' ;
13
13
import { getVersion } from './utils/version-utils' ;
14
+ import { isInCi } from './utils/is-ci' ;
15
+ import { isInContainer } from './utils/is-container' ;
14
16
15
17
/**
16
18
* Telemetry events
@@ -44,6 +46,8 @@ export class Telemetry {
44
46
private readonly prismaVersion = getPrismaVersion ( ) ;
45
47
private readonly isDocker = isDocker ( ) ;
46
48
private readonly isWsl = isWsl ( ) ;
49
+ private readonly isContainer = isInContainer ( ) ;
50
+ private readonly isCi = isInCi ;
47
51
private exitWait = 200 ;
48
52
49
53
constructor ( ) {
@@ -108,6 +112,8 @@ export class Telemetry {
108
112
prismaVersion : this . prismaVersion ,
109
113
isDocker : this . isDocker ,
110
114
isWsl : this . isWsl ,
115
+ isContainer : this . isContainer ,
116
+ isCi : this . isCi ,
111
117
...properties ,
112
118
} ;
113
119
this . mixpanel . track ( event , payload ) ;
Original file line number Diff line number Diff line change
1
+ import { env } from 'node:process' ;
2
+ export const isInCi = env . CI !== '0'
3
+ && env . CI !== 'false'
4
+ && (
5
+ 'CI' in env
6
+ || 'CONTINUOUS_INTEGRATION' in env
7
+ || Object . keys ( env ) . some ( key => key . startsWith ( 'CI_' ) )
8
+ ) ;
Original file line number Diff line number Diff line change
1
+ import fs from 'node:fs' ;
2
+ import isDocker from './is-docker' ;
3
+
4
+ let cachedResult : boolean | undefined ;
5
+
6
+ // Podman detection
7
+ const hasContainerEnv = ( ) => {
8
+ try {
9
+ fs . statSync ( '/run/.containerenv' ) ;
10
+ return true ;
11
+ } catch {
12
+ return false ;
13
+ }
14
+ } ;
15
+
16
+ export function isInContainer ( ) {
17
+ // TODO: Use `??=` when targeting Node.js 16.
18
+ if ( cachedResult === undefined ) {
19
+ cachedResult = hasContainerEnv ( ) || isDocker ( ) ;
20
+ }
21
+
22
+ return cachedResult ;
23
+ }
You can’t perform that action at this time.
0 commit comments