@@ -41,41 +41,48 @@ export const createJsVarName = (fileName: string): string => {
41
41
return fileName ;
42
42
} ;
43
43
44
+ /**
45
+ * Create a function that lowercases the first string parameter before passing it to the provided function
46
+ * @param fn the function to pass the lowercased path to
47
+ * @returns the result of the provided function
48
+ */
49
+ const lowerPathParam = ( fn : ( ( p : string ) => boolean ) ) => ( p : string ) => fn ( p . toLowerCase ( ) ) ;
50
+
44
51
/**
45
52
* Determine if a stringified file path is a TypeScript declaration file based on the extension at the end of the path.
46
53
* @param p the path to evaluate
47
54
* @returns `true` if the path ends in `.d.ts` (case-sensitive), `false` otherwise.
48
55
*/
49
- export const isDtsFile = ( p : string ) => p . endsWith ( '.d.ts' ) || p . endsWith ( '.d.mts' ) || p . endsWith ( '.d.cts' ) ;
56
+ export const isDtsFile = lowerPathParam ( ( p ) => p . endsWith ( '.d.ts' ) || p . endsWith ( '.d.mts' ) || p . endsWith ( '.d.cts' ) ) ;
50
57
51
58
/**
52
59
* Determine if a stringified file path is a TypeScript file based on the extension at the end of the path. This
53
60
* function does _not_ consider type declaration files (`.d.ts` files) to be TypeScript files.
54
61
* @param p the path to evaluate
55
62
* @returns `true` if the path ends in `.ts` (case-sensitive) but does _not_ end in `.d.ts`, `false` otherwise.
56
63
*/
57
- export const isTsFile = ( p : string ) => ! isDtsFile ( p ) && ( p . endsWith ( '.ts' ) || p . endsWith ( '.mts' ) || p . endsWith ( '.cts' ) ) ;
64
+ export const isTsFile = lowerPathParam ( ( p : string ) => ! isDtsFile ( p ) && ( p . endsWith ( '.ts' ) || p . endsWith ( '.mts' ) || p . endsWith ( '.cts' ) ) ) ;
58
65
59
66
/**
60
67
* Determine if a stringified file path is a TSX file based on the extension at the end of the path
61
68
* @param p the path to evaluate
62
69
* @returns `true` if the path ends in `.tsx` (case-sensitive), `false` otherwise.
63
70
*/
64
- export const isTsxFile = ( p : string ) => p . endsWith ( '.tsx' ) || p . endsWith ( '.mtsx' ) || p . endsWith ( '.ctsx' ) ;
71
+ export const isTsxFile = lowerPathParam ( ( p : string ) => p . endsWith ( '.tsx' ) || p . endsWith ( '.mtsx' ) || p . endsWith ( '.ctsx' ) ) ;
65
72
66
73
/**
67
74
* Determine if a stringified file path is a JSX file based on the extension at the end of the path
68
75
* @param p the path to evaluate
69
76
* @returns `true` if the path ends in `.jsx` (case-sensitive), `false` otherwise.
70
77
*/
71
- export const isJsxFile = ( p : string ) => p . endsWith ( '.jsx' ) || p . endsWith ( '.mjsx' ) || p . endsWith ( '.cjsx' ) ;
78
+ export const isJsxFile = lowerPathParam ( ( p : string ) => p . endsWith ( '.jsx' ) || p . endsWith ( '.mjsx' ) || p . endsWith ( '.cjsx' ) ) ;
72
79
73
80
/**
74
81
* Determine if a stringified file path is a JavaScript file based on the extension at the end of the path
75
82
* @param p the path to evaluate
76
83
* @returns `true` if the path ends in `.js` (case-sensitive), `false` otherwise.
77
84
*/
78
- export const isJsFile = ( p : string ) => p . endsWith ( '.js' ) || p . endsWith ( '.mjs' ) || p . endsWith ( '.cjs' ) ;
85
+ export const isJsFile = lowerPathParam ( ( p : string ) => p . endsWith ( '.js' ) || p . endsWith ( '.mjs' ) || p . endsWith ( '.cjs' ) ) ;
79
86
80
87
/**
81
88
* Generate the preamble to be placed atop the main file of the build
0 commit comments