From a7dd11364f8f08bfacfbc1b7b2663e162be4d08b Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Tue, 18 Aug 2026 21:53:36 -0700 Subject: [PATCH] Cast `parseEnv` result to `Record` Casting is required instead of a simple annotation because the default return value `NodeJS.Dict` sets the value to `string | undefined`. The `undefined` scenario is impossible with `parseEnv`'s current implementation, so to handle the the `undefined` case results in an untestable code branch. --- src/command.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/command.js b/src/command.js index 7b4a3f7..1035eb3 100644 --- a/src/command.js +++ b/src/command.js @@ -41,8 +41,9 @@ export async function encrypt(options = {}) { logger = {} } = options; - /** @type {Record} */ - const env = await readFile(inFile, { encoding: 'utf-8' }).then(parseEnv); + const env = /** @type {Record} */ ( + await readFile(inFile, { encoding: 'utf-8' }).then(parseEnv) + ); logger.debug?.('Environment variables read and parsed.'); if (Object.keys(env).length === 0) { logger.info?.('No environment variables found, aborting.'); @@ -121,8 +122,9 @@ export async function decrypt(options = {}, { args = [] } = {}) { logger = {} } = options; - /** @type {Record} */ - const env = await readFile(inFile, { encoding: 'utf-8' }).then(parseEnv); + const env = /** @type {Record} */ ( + await readFile(inFile, { encoding: 'utf-8' }).then(parseEnv) + ); logger.debug?.('Environment variables read and parsed.'); if (Object.keys(env).length === 0) { logger.info?.('No environment variables found, aborting.'); -- 2.47.3