UNPKG

@create-figma-plugin/build

Version:

Build a Figma/FigJam plugin/widget

29 lines 1.13 kB
import fs from 'node:fs'; import { dirname } from 'node:path'; import ts from 'typescript'; import { formatTypeScriptErrorMessage } from './format-typescript-error-message.js'; const parseConfigHost = { fileExists: ts.sys.fileExists, readDirectory: ts.sys.readDirectory, readFile: ts.sys.readFile, useCaseSensitiveFileNames: true }; export function readTsConfig() { const tsConfigFilePath = ts.findConfigFile(process.cwd(), ts.sys.fileExists, 'tsconfig.json'); if (typeof tsConfigFilePath === 'undefined') { throw new Error('Need a `tsconfig.json`'); } const jsonConfigFile = ts.readJsonConfigFile(tsConfigFilePath, function (path) { return fs.readFileSync(path, 'utf8'); }); const result = ts.parseJsonSourceFileConfigFileContent(jsonConfigFile, parseConfigHost, dirname(tsConfigFilePath)); if (result.errors.length > 0) { throw new Error(formatTypeScriptErrorMessage(result.errors)); } return { compilerOptions: result.options, filePaths: result.fileNames, tsConfigFilePath }; } //# sourceMappingURL=read-tsconfig.js.map