-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: tsconfig.json by default if tsconfig.build.json not exist
- Loading branch information
1 parent
1aac05e
commit 9bf163d
Showing
3 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as fs from 'fs'; | ||
import { join } from 'path'; | ||
|
||
const TSCONFIG_BUILD_JSON = 'tsconfig.build.json'; | ||
const TSCONFIG_JSON = 'tsconfig.json'; | ||
|
||
export function getDefaultTsconfigPath() { | ||
return fs.existsSync(join(process.cwd(), TSCONFIG_BUILD_JSON)) | ||
? TSCONFIG_BUILD_JSON | ||
: TSCONFIG_JSON; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as fs from 'fs'; | ||
import { getDefaultTsconfigPath } from '../../../lib/utils/get-default-tsconfig-path'; | ||
|
||
jest.mock('fs', () => { | ||
return { | ||
existsSync: jest.fn(), | ||
}; | ||
}); | ||
|
||
describe('get default tsconfig path', () => { | ||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
it('should get tsconfig.json when tsconfig.build.json not exist', () => { | ||
jest.spyOn(fs, 'existsSync').mockReturnValue(false); | ||
const result = getDefaultTsconfigPath(); | ||
expect(result).toBe('tsconfig.json'); | ||
}); | ||
it('should get tsconfig.build.json when tsconfig.build.json exist', () => { | ||
jest.spyOn(fs, 'existsSync').mockReturnValue(true); | ||
const result = getDefaultTsconfigPath(); | ||
expect(result).toBe('tsconfig.build.json'); | ||
}); | ||
}); |