@@ -98,7 +98,7 @@ const DEFAULTS = {
9898 cacheDirectory : process . env . TS_NODE_CACHE_DIRECTORY ,
9999 disableWarnings : yn ( process . env . TS_NODE_DISABLE_WARNINGS ) ,
100100 compiler : process . env . TS_NODE_COMPILER ,
101- compilerOptions : process . env . TS_NODE_COMPILER_OPTIONS ,
101+ compilerOptions : parse ( process . env . TS_NODE_COMPILER_OPTIONS ) ,
102102 project : process . env . TS_NODE_PROJECT ,
103103 ignore : split ( process . env . TS_NODE_IGNORE ) ,
104104 ignoreWarnings : split ( process . env . TS_NODE_IGNORE_WARNINGS ) ,
@@ -108,14 +108,21 @@ const DEFAULTS = {
108108/**
109109 * Split a string array of values.
110110 */
111- function split ( value : string | undefined ) {
111+ export function split ( value : string | undefined ) {
112112 return value ? value . split ( / * , * / g) : [ ]
113113}
114114
115+ /**
116+ * Parse a string as JSON.
117+ */
118+ export function parse ( value : string | undefined ) {
119+ return value ? JSON . parse ( value ) : undefined
120+ }
121+
115122/**
116123 * Replace backslashes with forward slashes.
117124 */
118- function slash ( value : string ) : string {
125+ export function slash ( value : string ) : string {
119126 return value . replace ( / \\ / g, '/' )
120127}
121128
@@ -138,6 +145,7 @@ export function register (options: Options = {}): () => Register {
138145 const fast = ! ! ( options . fast == null ? DEFAULTS . fast : options . fast )
139146 const project = options . project || DEFAULTS . project
140147 const cacheDirectory = options . cacheDirectory || DEFAULTS . cacheDirectory || join ( tmpdir ( ) , 'ts-node' )
148+ const compilerOptions = extend ( DEFAULTS . compilerOptions , options . compilerOptions )
141149 let result : Register
142150
143151 const ignore = (
@@ -146,14 +154,9 @@ export function register (options: Options = {}): () => Register {
146154 ( options . ignore === false ? [ ] : undefined ) :
147155 ( options . ignore || DEFAULTS . ignore )
148156 ) ||
149- [ '^ node_modules/' ]
157+ [ '/ node_modules/' ]
150158 ) . map ( str => new RegExp ( str ) )
151159
152- // Parse compiler options as JSON.
153- const compilerOptions = typeof options . compilerOptions === 'string' ?
154- JSON . parse ( options . compilerOptions ) :
155- options . compilerOptions
156-
157160 function load ( ) {
158161 const cache : Cache = { contents : { } , versions : { } , sourceMaps : { } }
159162
0 commit comments