smartenv/ts/smartenv.classes.helpers.ts

53 lines
937 B
TypeScript
Raw Normal View History

import * as plugins from './smartenv.plugins'
export let getEnvString = function (): string {
if (typeof window !== 'undefined') {
return 'browser'
} else if (typeof process !== 'undefined') {
return 'node'
}
2016-11-21 10:58:37 +00:00
}
2016-02-20 09:11:25 +00:00
export let getUserAgentString = function (): string {
if (isBrowser()) {
return navigator.userAgent
} else {
return undefined
}
2016-11-21 10:58:37 +00:00
}
2016-02-20 09:11:25 +00:00
export let isNode = function (): boolean {
return getEnvString() === 'node'
2016-11-21 10:58:37 +00:00
}
2016-02-20 09:11:25 +00:00
export let getNodeVersion = function (): string {
return process.version
2016-11-21 10:58:37 +00:00
}
2016-02-20 09:11:25 +00:00
export let isBrowser = function (): boolean {
return !isNode()
2016-11-21 10:58:37 +00:00
}
2016-02-20 09:11:25 +00:00
export let isCI = function () {
if (process.env.CI) {
return true
} else {
return false
};
2016-11-21 10:58:37 +00:00
}
2016-02-20 09:11:25 +00:00
export let isC9 = function () {
if (process.env.C9_HOSTNAME) {
return true
} else {
return false
}
2016-11-21 10:58:37 +00:00
}
2016-03-03 00:50:13 +00:00
export let isTravis = function () {
if (process.env.TRAVIS) {
return true
} else {
return false
};
2016-11-21 10:58:37 +00:00
}