updated path handling

This commit is contained in:
MasterGordon 2025-10-23 18:16:10 +02:00
parent 01a4022b9d
commit 77329562ec
3 changed files with 6 additions and 3 deletions

View File

@ -145,7 +145,7 @@ require("conform").setup({
formatters = { formatters = {
csharpierd = { csharpierd = {
command = "csharpierd", command = "csharpierd",
args = { "$FILENAME" }, args = { "$RELATIVE_FILEPATH" },
stdin = true, stdin = true,
}, },
}, },

View File

@ -199,6 +199,9 @@ async function formatCode(
fileContents: string, fileContents: string,
): Promise<string> { ): Promise<string> {
const state = await ensureServer(); const state = await ensureServer();
const filePath = path.isAbsolute(fileName)
? fileName
: path.join(process.cwd(), fileName);
try { try {
const response = await fetch(`http://localhost:${state.port}/format`, { const response = await fetch(`http://localhost:${state.port}/format`, {
@ -207,7 +210,7 @@ async function formatCode(
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
body: JSON.stringify({ body: JSON.stringify({
fileName: path.join(process.cwd(), fileName), fileName: filePath,
fileContents, fileContents,
}), }),
}); });

View File

@ -1,6 +1,6 @@
{ {
"name": "csharpierd", "name": "csharpierd",
"version": "1.0.1", "version": "1.0.2",
"description": "A persistent CSharpier formatting daemon with automatic server management and idle timeout", "description": "A persistent CSharpier formatting daemon with automatic server management and idle timeout",
"module": "index.ts", "module": "index.ts",
"type": "module", "type": "module",