• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

toddbluhm / env-cmd / 16245980298

13 Jul 2025 05:53AM UTC coverage: 97.001% (-1.2%) from 98.214%
16245980298

Pull #399

github

k-yle
feat: support loading TypeScript files
Pull Request #399: feat: support loading TypeScript files

287 of 309 branches covered (92.88%)

31 of 41 new or added lines in 5 files covered. (75.61%)

744 of 767 relevant lines covered (97.0%)

29.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.08
/src/utils.ts
1
import { resolve } from 'node:path'
4✔
2
import { homedir } from 'node:os'
4✔
3
import { cwd } from 'node:process'
4✔
4

4✔
5
// Special file extensions that node can natively import
4✔
6
export const IMPORT_HOOK_EXTENSIONS = [
4✔
7
  '.json',
4✔
8
  '.js',
4✔
9
  '.cjs',
4✔
10
  '.mjs',
4✔
11
  '.ts',
4✔
12
  '.mts',
4✔
13
  '.cts',
4✔
14
  '.tsx',
4✔
15
];
4✔
16

4✔
17
/**
4✔
18
 * A simple function for resolving the path the user entered
4✔
19
 */
4✔
20
export function resolveEnvFilePath(userPath: string): string {
4✔
21
  // Make sure a home directory exist
87✔
22
  const home = homedir() as string | undefined
87✔
23
  if (home != null) {
87✔
24
    userPath = userPath.replace(/^~($|\/|\\)/, `${home}$1`)
83✔
25
  }
83✔
26
  return resolve(cwd(), userPath)
87✔
27
}
87✔
28
/**
4✔
29
 * A simple function that parses a comma separated string into an array of strings
4✔
30
 */
4✔
31
export function parseArgList(list: string): string[] {
4✔
32
  return list.split(',')
36✔
33
}
36✔
34

4✔
35
/**
4✔
36
 * A simple function to test if the value is a promise/thenable
4✔
37
 */
4✔
38
export function isPromise<T>(value?: T | PromiseLike<T>): value is PromiseLike<T> {
4✔
39
  return value != null
67✔
40
    && typeof value === 'object'
59✔
41
    && 'then' in value
47✔
42
    && typeof value.then === 'function'
20✔
43
}
67✔
44

4✔
45
/** @returns true if the error is `ERR_UNKNOWN_FILE_EXTENSION` */
4✔
46
export function isLoaderError(error: unknown): error is Error {
4✔
47
  return (
16✔
48
    error instanceof Error &&
16✔
49
    'code' in error &&
16!
NEW
50
    error.code === 'ERR_UNKNOWN_FILE_EXTENSION'
×
51
  );
16✔
52
}
16✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc