1
- import { join } from 'path'
1
+ import { join , dirname } from 'path'
2
2
3
3
import test from 'ava'
4
4
import { omit } from 'lodash'
@@ -21,7 +21,7 @@ test('should RESPECT SWC_NODE_PROJECT env', (t) => {
21
21
process . env . SWC_NODE_PROJECT = configPath
22
22
const defaultOptions = readDefaultTsConfig ( )
23
23
const { config } = ts . readConfigFile ( configPath , ts . sys . readFile )
24
- const { options } = ts . parseJsonConfigFileContent ( config , ts . sys , process . cwd ( ) )
24
+ const { options } = ts . parseJsonConfigFileContent ( config , ts . sys , dirname ( configPath ) )
25
25
t . deepEqual ( omit ( defaultOptions , 'files' ) , options )
26
26
} )
27
27
@@ -32,6 +32,17 @@ test('should RESPECT TS_NODE_PROJECT env', (t) => {
32
32
process . env . TS_NODE_PROJECT = configPath
33
33
const defaultOptions = readDefaultTsConfig ( )
34
34
const { config } = ts . readConfigFile ( configPath , ts . sys . readFile )
35
- const { options } = ts . parseJsonConfigFileContent ( config , ts . sys , process . cwd ( ) )
35
+ const { options } = ts . parseJsonConfigFileContent ( config , ts . sys , dirname ( configPath ) )
36
+ t . deepEqual ( omit ( defaultOptions , 'files' ) , options )
37
+ } )
38
+
39
+ test ( 'should RESPECT tsconfig path in subdirectory' , ( t ) => {
40
+ const configPath = join ( __dirname , 'subdirectory/tsconfig.extend.json' )
41
+ delete process . env . SWC_NODE_PROJECT
42
+ delete process . env . TS_NODE_PROJECT
43
+ process . env . TS_NODE_PROJECT = configPath
44
+ const defaultOptions = readDefaultTsConfig ( )
45
+ const { config } = ts . readConfigFile ( configPath , ts . sys . readFile )
46
+ const { options } = ts . parseJsonConfigFileContent ( config , ts . sys , dirname ( configPath ) )
36
47
t . deepEqual ( omit ( defaultOptions , 'files' ) , options )
37
48
} )
0 commit comments