Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/config",
"version": "4.27.0",
"version": "5.0.0",
"description": "Cache and handle environment variables and config files of Athenna.",
"license": "MIT",
"author": "João Lenon <lenon@athenna.io>",
Expand Down Expand Up @@ -58,9 +58,9 @@
"syntax-error": "^1.4.0"
},
"devDependencies": {
"@athenna/common": "^4.46.0",
"@athenna/test": "^4.30.0",
"@athenna/tsconfig": "^4.19.0",
"@athenna/common": "^5.0.0",
"@athenna/test": "^5.0.0",
"@athenna/tsconfig": "^5.0.0",
"@types/lodash": "^4.17.7",
"@types/syntax-error": "^1.4.5",
"@typescript-eslint/eslint-plugin": "^7.18.0",
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/EnvHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,6 @@ export class EnvHelper {
return null
}

return envFlag
return envFlag as string
}
}
20 changes: 14 additions & 6 deletions tests/unit/config/ConfigTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export default class ConfigTest {
Config.clear()
process.env = Json.copy(this.env)
process.argv = Json.copy(this.argv)
await Folder.safeRemove(Path.fixtures('recursive-copy'))
}

@Test()
Expand Down Expand Up @@ -189,15 +188,15 @@ export default class ConfigTest {

@Test()
public async shouldThrownAnErrorWhenLoadingAConfigurationFileThatRecursivelyLoadsOther({ assert }: Context) {
const useCase = async () => await Config.load(Path.fixtures('config/recursiveOne.ts'))
const useCase = async () => await Config.load(Path.fixtures('recursive-config/recursiveOne.ts'))

await assert.rejects(useCase, RecursiveConfigException)
}

@Test()
public async shouldNotLoadMapAndDTSFiles({ assert }: Context) {
await Config.load(Path.config('app.d.ts'))
await Config.load(Path.config('app.js.map'))
await Config.load(Path.fixtures('config/app.d.ts'))
await Config.load(Path.fixtures('config/app.js.map'))

assert.equal(Config.get('app.name'), 'Athenna')
}
Expand Down Expand Up @@ -245,7 +244,7 @@ export default class ConfigTest {
public async shouldBeAbleToLoadAllConfigurationPathSafely({ assert }: Context) {
Config.set('app', {})

await Config.loadAll(Path.config(), true)
await Config.loadAll(Path.fixtures('config'), true)

assert.deepEqual(Config.get('app'), {})
}
Expand All @@ -255,7 +254,7 @@ export default class ConfigTest {
public async shouldBeAbleToLoadASingleFileInLoadAllMethod({ assert }: Context) {
Config.set('app', {})

await Config.loadAll(Path.config('app.ts'), true)
await Config.loadAll(Path.fixtures('config/app.ts'), true)

assert.deepEqual(Config.get('app'), {})
}
Expand Down Expand Up @@ -283,6 +282,9 @@ export default class ConfigTest {
}

@Test()
@Cleanup(async () => {
await Folder.safeRemove(Path.fixtures('recursive-copy'))
})
public async shouldBeAbleToRewriteTheConfigFileAndSaveModifications({ assert }: Context) {
const folder = await new Folder(Path.fixtures('recursive')).copy(Path.fixtures('recursive-copy'), {
withContent: true
Expand All @@ -308,6 +310,9 @@ export default class ConfigTest {
}

@Test()
@Cleanup(async () => {
await Folder.safeRemove(Path.fixtures('recursive-copy'))
})
public async shouldThrowAnExceptionIfCallingRewriteMethodWithABadKey({ assert }: Context) {
const folder = await new Folder(Path.fixtures('recursive')).copy(Path.fixtures('recursive-copy'), {
withContent: true
Expand All @@ -321,6 +326,9 @@ export default class ConfigTest {
}

@Test()
@Cleanup(async () => {
await Folder.safeRemove(Path.fixtures('recursive-copy'))
})
public async shouldThrowAnExceptionIfCallingRewriteMethodWithANotFoundKey({ assert }: Context) {
const folder = await new Folder(Path.fixtures('recursive')).copy(Path.fixtures('recursive-copy'), {
withContent: true
Expand Down