@@ -21,13 +21,14 @@ interface Argv {
21
21
help ?: boolean
22
22
compiler ?: string
23
23
project ?: string
24
+ require ?: string | string [ ]
24
25
ignoreWarnings ?: string | string [ ]
25
26
disableWarnings ?: boolean
26
27
compilerOptions ?: any
27
28
_ : string [ ]
28
29
}
29
30
30
- const strings = [ 'eval' , 'print' , 'compiler' , 'project' , 'ignoreWarnings' , 'cacheDirectory' ]
31
+ const strings = [ 'eval' , 'print' , 'compiler' , 'project' , 'ignoreWarnings' , 'require' , ' cacheDirectory']
31
32
const booleans = [ 'help' , 'fast' , 'lazy' , 'version' , 'disableWarnings' , 'cache' ]
32
33
33
34
const aliases : { [ key : string ] : string [ ] } = {
@@ -39,6 +40,7 @@ const aliases: { [key: string]: string[] } = {
39
40
print : [ 'p' ] ,
40
41
project : [ 'P' ] ,
41
42
compiler : [ 'C' ] ,
43
+ require : [ 'r' ] ,
42
44
cacheDirectory : [ 'cache-directory' ] ,
43
45
ignoreWarnings : [ 'I' , 'ignore-warnings' ] ,
44
46
disableWarnings : [ 'D' , 'disable-warnings' ] ,
@@ -119,6 +121,7 @@ Options:
119
121
120
122
-e, --eval [code] Evaluate code
121
123
-p, --print [code] Evaluate code and print result
124
+ -r, --require [path] Require a node module for execution
122
125
-C, --compiler [name] Specify a custom TypeScript compiler
123
126
-I, --ignoreWarnings [code] Ignore TypeScript warnings by diagnostic code
124
127
-D, --disableWarnings Ignore every TypeScript warning
@@ -167,6 +170,12 @@ const EVAL_PATH = join(cwd, EVAL_FILENAME)
167
170
// Store eval contents for in-memory lookups.
168
171
const evalFile = { input : '' , output : '' , version : 0 }
169
172
173
+ // Require specified modules before start-up.
174
+ for ( const id of arrify ( argv . require ) ) {
175
+ Module . _load ( id )
176
+ }
177
+
178
+ // Execute the main contents (either eval, script or piped).
170
179
if ( isEvalScript ) {
171
180
evalAndExit ( code , isPrinted )
172
181
} else {
0 commit comments