All files / infrastructure/files tsconfig.file.util.ts

70.59% Statements 12/17
25% Branches 1/4
25% Functions 1/4
70.59% Lines 12/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 361x   1x 1x 1x   1x       1x       1x       1x                 1x 6x 6x       6x    
import { ts } from 'ts-morph';
 
const getCurrentDirectory = ts.sys.getCurrentDirectory;
const useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames;
const newLine = ts.sys.newLine;
 
export function getNewLine(): string {
    return newLine;
}
 
export function cleanNameWithoutSpaceAndToLowerCase(name: string): string {
    return name.toLowerCase().replace(/ /g, '-');
}
 
export function getCanonicalFileName(fileName: string): string {
    return useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
}
 
export const formatDiagnosticsHost: ts.FormatDiagnosticsHost = {
    getCurrentDirectory,
    getCanonicalFileName,
    getNewLine
};
 
/**
 * Read and parse tsconfig file with tsc APIs
 */
export function readTsconfigFile(tsconfigFile: string): any {
    let result = ts.readConfigFile(tsconfigFile, ts.sys.readFile);
    Iif (result.error) {
        let message = ts.formatDiagnostics([result.error], formatDiagnosticsHost);
        throw new Error(message);
    }
    return result.config;
}