smartenv/ts/smartenv.classes.helpers.ts

49 lines
938 B
TypeScript
Raw Normal View History

2016-02-20 09:11:25 +00:00
/// <reference path="typings/main.d.ts" />
export var getEnvString = function():string {
if (typeof window !== "undefined") {
return "browser";
} else if (typeof process !== "undefined") {
return "node";
}
};
export var getUserAgentString = function():string{
if(isBrowser()){
return navigator.userAgent;
} else {
return undefined;
}
};
export var isNode = function():boolean {
if (getEnvString() === "node"){
return true;
} else {
return false;
}
};
export var getNodeVersion = function():string {
return process.version;
};
export var isBrowser = function():boolean {
return !isNode();
};
export var isCI = function(){
if(process.env.CI){
return true;
} else {
return false;
};
};
export var isTravis = function(){
if(process.env.TRAVIS){
return true;
} else {
return false;
};
};