Commit 9797bf62 authored by mohoff's avatar mohoff Committed by chapati

chore: use optional chaining

parent d56ea9e1
Pipeline #23205 passed with stages
in 1 minute and 50 seconds
type JSON = string | number | boolean | null | JSON[] | { [key: string]: JSON }
type JSON = string | number | boolean | null | JSON[] | JSONObject
export type JSONObject = { [key: string]: JSON }
export type BaseConfig = JSONObject
......
......@@ -9,7 +9,7 @@ const hasSopsMetadata = R.has('sops')
const runSopsWithOptions = (options: string[]): string => {
const { stdout, stderr } = execa.sync('sops', options)
if (stderr && stderr.toString().length) {
if (stderr?.toString().length) {
throw new Error(stderr.toString())
}
......@@ -25,7 +25,7 @@ export const decryptToObject = (
}
// If there's no SOPS metadata, parsedConfig already represents decrypted config
if (parsedConfig && !hasSopsMetadata(parsedConfig)) {
if (!hasSopsMetadata(parsedConfig)) {
return parsedConfig
}
......
import R from 'ramda'
export const substituteWithEnv = (substitutionPattern: string) => (
stringContent: string
): string =>
stringContent.replace(
new RegExp(substitutionPattern, 'g'),
(original, key: string) => {
if (!R.has(key, process.env) || R.isNil(process.env[key])) {
if (!process.env?.[key]) {
throw new Error(`process.env is missing key "${key}"`)
}
......
......@@ -31,9 +31,7 @@ export const validate = (
}
// Resolve absolute paths of all given `normalizedConfigPaths`, which can be passed as directories and/or files
// TODO: Figure out correct type here. Error: R.compose<string[], (string | string[])[], string[]>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const flatConfigPaths = R.compose<string[], any[], string[]>(
const flatConfigPaths = R.compose<string[], (string | string[])[], string[]>(
R.flatten,
R.map(configPath =>
fs.lstatSync(configPath).isDirectory()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment