1- import { join } from 'path'
1+ import { join , dirname } from 'path'
22
33import test from 'ava'
44import { omit } from 'lodash'
@@ -21,7 +21,7 @@ test('should RESPECT SWC_NODE_PROJECT env', (t) => {
2121 process . env . SWC_NODE_PROJECT = configPath
2222 const defaultOptions = readDefaultTsConfig ( )
2323 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 ) )
2525 t . deepEqual ( omit ( defaultOptions , 'files' ) , options )
2626} )
2727
@@ -32,6 +32,17 @@ test('should RESPECT TS_NODE_PROJECT env', (t) => {
3232 process . env . TS_NODE_PROJECT = configPath
3333 const defaultOptions = readDefaultTsConfig ( )
3434 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 ) )
3647 t . deepEqual ( omit ( defaultOptions , 'files' ) , options )
3748} )
0 commit comments