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 = {
csharpierd = {
command = "csharpierd",
args = { "$FILENAME" },
args = { "$RELATIVE_FILEPATH" },
stdin = true,
},
},

View File

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

View File

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