36 lines
4.2 KiB
JavaScript
36 lines
4.2 KiB
JavaScript
"use strict";
|
|
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) {
|
|
console.log("running on NODE");
|
|
var smartenvVersion = require("../package.json").version;
|
|
console.log("node version is " + this.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
|
|
}
|
|
else {
|
|
console.log("running on BROWSER");
|
|
console.log("browser is " + this.getEnv().userAgent);
|
|
}
|
|
console.log("the smartenv registration store currently holds the following properties:");
|
|
console.log(Object.getOwnPropertyNames(objectStorage.obs.getAll()));
|
|
};
|
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZW52LmVudmlyb25tZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFLQSxJQUFPLE9BQU8sV0FBVyxvQkFBb0IsQ0FBQyxDQUFDO0FBQy9DLElBQU8sYUFBYSxXQUFXLDBCQUEwQixDQUFDLENBQUM7QUFHM0QsSUFBSSxXQUErQixDQUFDO0FBQ3BDLElBQUksYUFBYSxHQUFXLEtBQUssQ0FBQztBQUVsQzs7O0dBR0c7QUFDUSxjQUFNLEdBQUc7SUFDaEIsRUFBRSxDQUFDLENBQUMsQ0FBQyxhQUFhLENBQUMsQ0FBQyxDQUFDO1FBQ2pCLFdBQVcsR0FBRyxJQUFJLE9BQU8sQ0FBQyxXQUFXLEVBQUUsQ0FBQztRQUN4QyxhQUFhLEdBQUcsSUFBSSxDQUFDLENBQUMsbUNBQ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