Skip to content

Commit

Permalink
feat: clean up values-repo file
Browse files Browse the repository at this point in the history
  • Loading branch information
j-zimnowoda committed Feb 7, 2025
1 parent 377f154 commit 05ccba6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/common/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { chalk } from 'zx'
import { decrypt } from './crypt'
import { terminal } from './debug'
import { env } from './envalid'
import { unsetValuesFile, unsetValuesFileSync } from './repo'
import { isCore } from './utils'

chalk.level = 2
Expand Down Expand Up @@ -39,15 +40,17 @@ export const prepareEnvironment = async (options?: PrepareEnvironmentOptions): P
if (!options?.skipEnvDirCheck && (await isReadyEnvDir())) {
if (!options?.skipDecrypt) await decrypt()
}
await unsetValuesFile(env.ENV_DIR)

Check warning on line 43 in src/common/cli.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

/**
* Cleanup trap on exit - any handler function MUST be synchronous
* @param handler cleanup function set per command
*/
export const cleanupHandler = (handler: () => any): void => {
export const cleanupHandler = (handler: () => any) => {

Check warning on line 50 in src/common/cli.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
process.on('exit', (code) => {
handler()
unsetValuesFileSync(env.ENV_DIR)

Check warning on line 53 in src/common/cli.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
process.exit(code)
})

Check warning on line 55 in src/common/cli.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}
7 changes: 7 additions & 0 deletions src/common/repo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { randomUUID } from 'crypto'
import { rmSync } from 'fs'
import { pathExists } from 'fs-extra'
import { rm, writeFile } from 'fs/promises'
import { globSync } from 'glob'
Expand Down Expand Up @@ -383,6 +384,12 @@ export const unsetValuesFile = async (envDir: string): Promise<string> => {
return valuesPath
}

export const unsetValuesFileSync = (envDir: string): string => {

Check warning on line 387 in src/common/repo.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
const valuesPath = path.join(envDir, 'values-repo.yaml')

Check warning on line 388 in src/common/repo.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
rmSync(valuesPath, { force: true })

Check warning on line 389 in src/common/repo.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
return valuesPath

Check warning on line 390 in src/common/repo.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

export const loadValues = async (envDir: string, deps = { loadToSpec }): Promise<Record<string, any>> => {
const fileMaps = getFileMaps(envDir)
const spec = {}
Expand Down

0 comments on commit 05ccba6

Please sign in to comment.