UNPKG

@dotenvx/dotenvx-radar

Version:
48 lines (35 loc) 1.19 kB
const si = require('systeminformation') const dotenvx = require('@dotenvx/dotenvx') const Session = require('./../db/session') const PostObserve = require('./api/postObserve') const gitUrl = require('./helpers/gitUrl') const gitBranch = require('./helpers/gitBranch') const observe = async function (encoded, options = {}) { const sesh = new Session() // TODO: handle scenario where constructor fails let hostname = process.env.DOTENVX_RADAR_HOSTNAME || options.hostname if (!hostname) { hostname = sesh.hostname() } let token = process.env.DOTENVX_RADAR_TOKEN || options.token if (!token) { token = sesh.token() } const _pwd = process.cwd() const _gitUrl = gitUrl() const _gitBranch = gitBranch() const system = await si.system() const _systemUuid = system.uuid const osInfo = await si.osInfo() const _osPlatform = osInfo.platform const _osArch = osInfo.arch const json = await new PostObserve(hostname, token, encoded, _pwd, _gitUrl, _gitBranch, _systemUuid, _osPlatform, _osArch).run() return json } const config = function (options = {}) { return dotenvx.config(options) } module.exports = { observe, // dotenv proxies config }