@lokalise/node-core
Advanced tools
Comparing version 6.0.0 to 6.1.0
@@ -21,2 +21,3 @@ import type { EnvValueValidator } from './configTypes'; | ||
getOptionalTransformed(param: string, defaultValue: string, transformer: (value: string) => string): string; | ||
getOptionalNullableTransformed<T extends string | undefined>(param: string, defaultValue: T, transformer: (value: T | string) => T | string): T | string; | ||
getMandatoryTransformed(param: string, transformer: (value: string) => string): string; | ||
@@ -23,0 +24,0 @@ getOptionalBoolean(param: string, defaultValue: boolean): boolean; |
@@ -97,2 +97,6 @@ "use strict"; | ||
} | ||
getOptionalNullableTransformed(param, defaultValue, transformer) { | ||
const value = this.env[param] || defaultValue; | ||
return transformer(value); | ||
} | ||
getMandatoryTransformed(param, transformer) { | ||
@@ -99,0 +103,0 @@ const value = this.getMandatory(param); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
const process = tslib_1.__importStar(require("process")); | ||
const ConfigScope_1 = require("./ConfigScope"); | ||
const configTransformers_1 = require("./configTransformers"); | ||
const configValidators_1 = require("./configValidators"); | ||
const maybeEnsureClosingSlashTransformer = (value) => { | ||
if (!value) { | ||
return undefined; | ||
} | ||
const lastChar = value.at(-1); | ||
if (lastChar !== '/') { | ||
return `${value}/`; | ||
} | ||
return value; | ||
}; | ||
describe('ConfigScope', () => { | ||
@@ -307,2 +315,28 @@ describe('getMandatoryInteger', () => { | ||
}); | ||
describe('getOptionalNullableTransformed', () => { | ||
it('transforms value', () => { | ||
process.env.value = 'val'; | ||
const configScope = new ConfigScope_1.ConfigScope(); | ||
const resolvedValue = configScope.getOptionalNullableTransformed('value', 'def/', maybeEnsureClosingSlashTransformer); | ||
expect(resolvedValue).toBe('val/'); | ||
}); | ||
it('uses default value if not set', () => { | ||
delete process.env.value; | ||
const configScope = new ConfigScope_1.ConfigScope(); | ||
const resolvedValue = configScope.getOptionalNullableTransformed('value', 'def', maybeEnsureClosingSlashTransformer); | ||
expect(resolvedValue).toBe('def/'); | ||
}); | ||
it('uses default undefined value if not set', () => { | ||
delete process.env.value; | ||
const configScope = new ConfigScope_1.ConfigScope(); | ||
const resolvedValue = configScope.getOptionalNullableTransformed('value', undefined, maybeEnsureClosingSlashTransformer); | ||
expect(resolvedValue).toBeUndefined(); | ||
}); | ||
it('uses default value on empty string', () => { | ||
process.env.value = ''; | ||
const configScope = new ConfigScope_1.ConfigScope(); | ||
const resolvedValue = configScope.getOptionalNullableTransformed('value', 'def', maybeEnsureClosingSlashTransformer); | ||
expect(resolvedValue).toBe('def/'); | ||
}); | ||
}); | ||
describe('getMandatoryTransformed', () => { | ||
@@ -309,0 +343,0 @@ it('transforms value', () => { |
@@ -1,2 +0,2 @@ | ||
declare const _default: import("vitest/dist/config").UserConfigExport; | ||
declare const _default: import("vite").UserConfig; | ||
export default _default; |
@@ -19,2 +19,3 @@ "use strict"; | ||
'src/errors/globalErrorHandler.ts', | ||
'src/config/configTransformers.ts' | ||
], | ||
@@ -21,0 +22,0 @@ reporter: ['text'], |
{ | ||
"name": "@lokalise/node-core", | ||
"version": "6.0.0", | ||
"version": "6.1.0", | ||
"author": { | ||
@@ -38,11 +38,11 @@ "name": "Lokalise", | ||
"dependencies": { | ||
"pino": "^8.14.1", | ||
"undici": "^5.22.1", | ||
"pino": "^8.15.0", | ||
"undici": "^5.23.0", | ||
"undici-retry": "^2.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.3.2", | ||
"@typescript-eslint/eslint-plugin": "^5.62.0", | ||
"@typescript-eslint/parser": "^5.62.0", | ||
"@vitest/coverage-v8": "^0.32.2", | ||
"@types/node": "^20.4.9", | ||
"@typescript-eslint/eslint-plugin": "^6.3.0", | ||
"@typescript-eslint/parser": "^6.3.0", | ||
"@vitest/coverage-v8": "^0.34.1", | ||
"auto-changelog": "^2.4.0", | ||
@@ -56,5 +56,5 @@ "eslint": "^8.43.0", | ||
"typescript": "^5.1.6", | ||
"vitest": "^0.32.2", | ||
"vitest": "^0.34.1", | ||
"zod": "^3.21.4" | ||
} | ||
} |
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
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
209566
2563
70
Updatedpino@^8.15.0
Updatedundici@^5.23.0