Skip to main content
Glama
SiroSuzume

MCP ts-morph Refactoring Tools

by SiroSuzume
create-source-file-if-not-exists.ts888 B
import type { Project, SourceFile } from "ts-morph"; /** * 指定されたパスにファイルが存在しない場合、新しいソースファイルを作成します。 * 既にファイルが存在する場合は、既存の SourceFile オブジェクトを返します。 * * @param project - ts-morph の Project インスタンス。 * @param filePath - 作成または取得するファイルの絶対パス。 * @param content - ファイルが存在しない場合に書き込む内容。 * @returns 作成された、または既存の SourceFile オブジェクト。 */ export function createSourceFileIfNotExists( project: Project, filePath: string, content: string, ): SourceFile { const existingSourceFile = project.getSourceFile(filePath); if (existingSourceFile) { return existingSourceFile; } return project.createSourceFile(filePath, content); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/SiroSuzume/mcp-ts-morph'

If you have feedback or need assistance with the MCP directory API, please join our Discord server