Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function createNodeExtension({
contextPath = process.cwd(),
configLookup = true,
configFileName,
configFilePath = configLookup ? ts.findConfigFile(contextPath, fileExists, configFileName) : undefined,
compilerOptions: noConfigOptions = defaultCompilerOptions,
cacheDirectoryPath = findCacheDirectory(contextPath),
installSourceMapSupport = !process.execArgv.includes('--enable-source-maps'),
autoScriptTarget = true
}: ICreateNodeExtensionOptions = {}): NodeExtension {
const formatDiagnosticsHost: ts.FormatDiagnosticsHost = {
getCurrentDirectory: () => contextPath,
getCanonicalFileName: getCanonicalPath,
getNewLine
};
const compilerOptions: ts.CompilerOptions = {};
if (typeof configFilePath === 'string') {
const { options, errors } = readAndParseConfigFile(configFilePath);
if (errors.length) {
throw new Error(ts.formatDiagnostics(errors, formatDiagnosticsHost));
}