How to use the @ts-tools/transpile.findCacheDirectory function in @ts-tools/transpile

To help you get started, we’ve selected a few @ts-tools/transpile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AviVahl / ts-tools / packages / node / src / node-extension.ts View on Github external
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));
        }