@backstage/config
Advanced tools
Comparing version 0.1.1-alpha.21 to 0.1.1-alpha.22
@@ -35,2 +35,5 @@ 'use strict'; | ||
return `Missing required config value at '${key}'`; | ||
}, | ||
convert(key, context, expected) { | ||
return `Unable to convert config value for key '${key}' in '${context}' to a ${expected}`; | ||
} | ||
@@ -137,3 +140,11 @@ }; | ||
getOptionalNumber(key) { | ||
return this.readConfigValue(key, (value) => typeof value === "number" || {expected: "number"}); | ||
const value = this.readConfigValue(key, (val) => typeof val === "number" || typeof val === "string" || {expected: "number"}); | ||
if (typeof value === "number" || value === void 0) { | ||
return value; | ||
} | ||
const number = Number(value); | ||
if (!Number.isFinite(number)) { | ||
throw new Error(errors.convert(this.fullKey(key), this.context, "number")); | ||
} | ||
return number; | ||
} | ||
@@ -140,0 +151,0 @@ getBoolean(key) { |
@@ -29,2 +29,5 @@ import cloneDeep2 from 'lodash/cloneDeep'; | ||
return `Missing required config value at '${key}'`; | ||
}, | ||
convert(key, context, expected) { | ||
return `Unable to convert config value for key '${key}' in '${context}' to a ${expected}`; | ||
} | ||
@@ -131,3 +134,11 @@ }; | ||
getOptionalNumber(key) { | ||
return this.readConfigValue(key, (value) => typeof value === "number" || {expected: "number"}); | ||
const value = this.readConfigValue(key, (val) => typeof val === "number" || typeof val === "string" || {expected: "number"}); | ||
if (typeof value === "number" || value === void 0) { | ||
return value; | ||
} | ||
const number = Number(value); | ||
if (!Number.isFinite(number)) { | ||
throw new Error(errors.convert(this.fullKey(key), this.context, "number")); | ||
} | ||
return number; | ||
} | ||
@@ -134,0 +145,0 @@ getBoolean(key) { |
{ | ||
"name": "@backstage/config", | ||
"description": "Config API used by Backstage core, backend, and CLI", | ||
"version": "0.1.1-alpha.21", | ||
"version": "0.1.1-alpha.22", | ||
"private": false, | ||
@@ -42,4 +42,4 @@ "publishConfig": { | ||
], | ||
"gitHead": "c5a4834557b9f8265c24af1b13c12614daf99470", | ||
"gitHead": "777cda358f1c50f59fedc8c3a35d76a5cc4e6271", | ||
"module": "dist/index.esm.js" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29259
510