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';
1111import { isWsl } from './utils/is-wsl' ;
1212import { getMachineId } from './utils/machine-id-utils' ;
1313import { getVersion } from './utils/version-utils' ;
14+ import { isInCi } from './utils/is-ci' ;
15+ import { isInContainer } from './utils/is-container' ;
1416
1517/**
1618 * Telemetry events
@@ -44,6 +46,8 @@ export class Telemetry {
4446 private readonly prismaVersion = getPrismaVersion ( ) ;
4547 private readonly isDocker = isDocker ( ) ;
4648 private readonly isWsl = isWsl ( ) ;
49+ private readonly isContainer = isInContainer ( ) ;
50+ private readonly isCi = isInCi ;
4751 private exitWait = 200 ;
4852
4953 constructor ( ) {
@@ -108,6 +112,8 @@ export class Telemetry {
108112 prismaVersion : this . prismaVersion ,
109113 isDocker : this . isDocker ,
110114 isWsl : this . isWsl ,
115+ isContainer : this . isContainer ,
116+ isCi : this . isCi ,
111117 ...properties ,
112118 } ;
113119 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