@ulixee/commons
Advanced tools
Comparing version 2.0.0-alpha.12 to 2.0.0-alpha.13
@@ -10,3 +10,3 @@ export default class UlixeeConfig { | ||
private static cachedConfigObjects; | ||
serverHost?: string; | ||
defaultMinerHost?: string; | ||
databoxOutDir?: string; | ||
@@ -25,3 +25,3 @@ private get configPath(); | ||
export interface IUlixeeConfig { | ||
serverHost?: string; | ||
defaultMinerHost?: string; | ||
databoxOutDir?: string; | ||
@@ -28,0 +28,0 @@ } |
@@ -12,3 +12,3 @@ "use strict"; | ||
const data = JSON.parse(Fs.readFileSync(this.configPath, 'utf8')); | ||
this.serverHost = data.serverHost; | ||
this.defaultMinerHost = data.serverHost; | ||
if (data.databoxOutDir) { | ||
@@ -31,3 +31,3 @@ this.databoxOutDir = Path.isAbsolute(data.databoxOutDir) ? data.databoxOutDir : Path.resolve(this.directoryPath, data.databoxOutDir); | ||
return { | ||
serverHost: this.serverHost, | ||
defaultMinerHost: this.defaultMinerHost, | ||
databoxOutDir: this.databoxOutDir, | ||
@@ -34,0 +34,0 @@ }; |
@@ -9,3 +9,3 @@ /** | ||
export declare function parseEnvPath(envvar: string, relativeTo?: string): string; | ||
export declare function parseEnvBool(envvar: string): boolean; | ||
export declare function parseEnvBool(envvar: string): boolean | undefined; | ||
export declare function parseEnvBigint(envvar: string): bigint | null; |
@@ -7,2 +7,3 @@ "use strict"; | ||
const Os = require("os"); | ||
const dirUtils_1 = require("./dirUtils"); | ||
/** | ||
@@ -70,5 +71,9 @@ * Will load env files with this precedence (.env.defaults, .env.<NODE_ENV>, .env) | ||
if (!envvar) | ||
return null; | ||
return undefined; | ||
if (envvar?.startsWith('~')) | ||
envvar = Path.join(Os.homedir(), envvar.slice(1)); | ||
if (envvar?.startsWith('<CACHE>')) | ||
envvar = envvar.replace('<CACHE>', (0, dirUtils_1.getCacheDirectory)()); | ||
if (envvar?.startsWith('<TMP>')) | ||
envvar = envvar.replace('<TMP>', Os.tmpdir()); | ||
if (Path.isAbsolute(envvar)) | ||
@@ -80,5 +85,9 @@ return envvar; | ||
function parseEnvBool(envvar) { | ||
if (envvar === null || envvar === undefined) | ||
return undefined; | ||
if (envvar === '1' || envvar?.toLowerCase() === 'true' || envvar?.toLowerCase() === 'yes') | ||
return true; | ||
return false; | ||
if (envvar === '0' || envvar?.toLowerCase() === 'false' || envvar?.toLowerCase() === 'no') { | ||
return false; | ||
} | ||
} | ||
@@ -85,0 +94,0 @@ exports.parseEnvBool = parseEnvBool; |
@@ -20,3 +20,3 @@ "use strict"; | ||
const result = {}; | ||
for (const [key, value] of Object.keys(object)) { | ||
for (const [key, value] of Object.entries(object)) { | ||
if (!keys.includes(key)) { | ||
@@ -23,0 +23,0 @@ result[key] = value; |
{ | ||
"name": "@ulixee/commons", | ||
"version": "2.0.0-alpha.12", | ||
"version": "2.0.0-alpha.13", | ||
"description": "Common utilities for Ulixee", | ||
@@ -19,3 +19,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "f4dcca3a1da1cba8dcc791a853647d60af5c02bd" | ||
"gitHead": "0c45d1ed34dc323129fba1a526c460466130b27e" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
225115
3266