mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +08:00
26 lines
904 B
TypeScript
26 lines
904 B
TypeScript
import * as ts from 'typescript';
|
|
|
|
export function getCompilerOptionsFromTSConfig(tsConfigPath: string): ts.CompilerOptions {
|
|
const parseConfigFileHost: ts.ParseConfigFileHost = {
|
|
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
useCaseSensitiveFileNames: false,
|
|
readDirectory: ts.sys.readDirectory,
|
|
fileExists: ts.sys.fileExists,
|
|
readFile: ts.sys.readFile,
|
|
onUnRecoverableConfigFileDiagnostic: undefined,
|
|
};
|
|
|
|
const tsConfig = ts.getParsedCommandLineOfConfigFile(tsConfigPath, ts.getDefaultCompilerOptions(), parseConfigFileHost);
|
|
|
|
const compilerOptions: ts.CompilerOptions = tsConfig.options || ts.getDefaultCompilerOptions();
|
|
|
|
return compilerOptions;
|
|
}
|
|
|
|
export function getNoEmitOnErrorFromTSConfig(tsConfigPath: string): boolean {
|
|
const compilerOptions = getCompilerOptionsFromTSConfig(tsConfigPath);
|
|
const noEmitOnError = !!compilerOptions.noEmitOnError;
|
|
|
|
return noEmitOnError;
|
|
}
|