Convert to typescript
This commit is contained in:
parent
0f423da02c
commit
f8274253bd
19 changed files with 2157 additions and 488 deletions
22
src/isDocker.ts
Normal file
22
src/isDocker.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import * as fs from 'fs'
|
||||
|
||||
function hasDockerEnv(): boolean {
|
||||
try {
|
||||
fs.statSync('/.dockerenv')
|
||||
return true
|
||||
} catch (_) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function hasDockerCGroup(): boolean {
|
||||
try {
|
||||
return fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker')
|
||||
} catch (_) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export function isDocker(): boolean {
|
||||
return hasDockerEnv() || hasDockerCGroup()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue