Convert to typescript

This commit is contained in:
Peter Evans 2020-05-17 17:21:11 +09:00
parent 0f423da02c
commit f8274253bd
19 changed files with 2157 additions and 488 deletions

22
src/isDocker.ts Normal file
View 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()
}