40 lines
4.6 KiB
JavaScript
40 lines
4.6 KiB
JavaScript
/// <reference path="typings/main.d.ts" />
|
|
/**
|
|
* Deals with the environment the current JS script is running in.
|
|
*/
|
|
var plugins = require("./smartenv.plugins");
|
|
var classes = require("./smartenv.classes");
|
|
var objectStorage = require("./smartenv.objectstorage");
|
|
var environment;
|
|
var envDetermined = false;
|
|
/**
|
|
* returns the environment
|
|
* @returns {Environment}
|
|
*/
|
|
exports.getEnv = function () {
|
|
if (!envDetermined) {
|
|
environment = new classes.Environment();
|
|
envDetermined = true; // ensure code above only runs once
|
|
}
|
|
;
|
|
return environment;
|
|
};
|
|
/**
|
|
* prints the environment to console
|
|
*/
|
|
exports.printEnv = function () {
|
|
if (this.getEnv().isNode) {
|
|
plugins.beautylog.ok("running on NODE");
|
|
var smartenvVersion = require("../package.json").version;
|
|
plugins.beautylog.log("node version is " + this.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
|
|
}
|
|
else {
|
|
plugins.beautylog.ok("running on BROWSER");
|
|
plugins.beautylog.log("browser is " + this.getEnv().userAgent);
|
|
}
|
|
plugins.beautylog.log("the smartenv registration store currently holds the following properties:");
|
|
console.log(Object.getOwnPropertyNames(objectStorage.obs.getAll()));
|
|
};
|
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZW52LmVudmlyb25tZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDBDQUEwQztBQUMxQzs7R0FFRztBQUNILElBQU8sT0FBTyxXQUFXLG9CQUFvQixDQUFDLENBQUM7QUFDL0MsSUFBTyxPQUFPLFdBQVcsb0JBQW9CLENBQUMsQ0FBQztBQUMvQyxJQUFPLGFBQWEsV0FBVywwQkFBMEIsQ0FBQyxDQUFDO0FBRzNELElBQUksV0FBK0IsQ0FBQztBQUNwQyxJQUFJLGFBQWEsR0FBVyxLQUFLLENBQUM7QUFFbEM7OztHQUdHO0FBQ1E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