]> git.ardis.lu - envpass/commitdiff
Cast `parseEnv` result to `Record<string, string>`
authorArdis Lu <ardisglu@gmail.com>
Wed, 19 Aug 2026 04:53:36 +0000 (21:53 -0700)
committerArdis Lu <ardisglu@gmail.com>
Wed, 19 Aug 2026 04:53:36 +0000 (21:53 -0700)
Casting is required instead of a simple annotation because the default return value `NodeJS.Dict<string>` 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

index 7b4a3f767f74eb4d04dab1427eb799f3dfede6d2..1035eb386d73142ffc4df67ff53a930038045a34 100644 (file)
@@ -41,8 +41,9 @@ export async function encrypt(options = {}) {
     logger = {}
   } = options;
 
-  /** @type {Record<string, string>} */
-  const env = await readFile(inFile, { encoding: 'utf-8' }).then(parseEnv);
+  const env = /** @type {Record<string, string>} */ (
+    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<string, string>} */
-  const env = await readFile(inFile, { encoding: 'utf-8' }).then(parseEnv);
+  const env = /** @type {Record<string, string>} */ (
+    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.');
This page took 0.039681 seconds and 4 git commands to generate.