From e5bfbf60e88a1333669755500182b8fc4ac0819e Mon Sep 17 00:00:00 2001 From: MinUk Song Date: Tue, 11 Jun 2024 18:17:21 +0900 Subject: [PATCH] fix: filepath --- lib/publish.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/publish.ts b/lib/publish.ts index 42af9f4..6886c85 100644 --- a/lib/publish.ts +++ b/lib/publish.ts @@ -5,6 +5,7 @@ import path from "node:path"; import os from "node:os"; import axios, {AxiosError} from "axios"; import urlJoin from "url-join"; +import {execSync} from "child_process"; export async function publish(userConfig: UserConfig, context: PrepareContext): Promise { const config = resolvePluginConfig(userConfig, context); @@ -19,6 +20,7 @@ export async function publish(userConfig: UserConfig, context: PrepareContext): commit_message: config.commitTitle, actions: [], }; + const repositoryDir = execSync("git rev-parse --show-toplevel", {encoding: "utf-8", cwd: context.cwd}).trim(); for (const asset of config.assets) { const assetPath = resolve(asset.path, context.cwd); if (!await fileExists(assetPath)) { @@ -29,7 +31,7 @@ export async function publish(userConfig: UserConfig, context: PrepareContext): body.actions.push({ action: "update", - file_path: asset.path, + file_path: path.relative(repositoryDir, assetPath), encoding: "text", content: assetContent, } as never); @@ -37,9 +39,8 @@ export async function publish(userConfig: UserConfig, context: PrepareContext): try { const instance = axios.create({}); - await instance.get(urlJoin(config.gitlabBaseUrl, 'repository', 'commits'), { + await instance.post(urlJoin(config.gitlabBaseUrl, 'repository', 'commits'), body, { headers: {"PRIVATE-TOKEN": config.gitlabToken, "Content-Type": "application/json"}, - data: JSON.stringify(body), }); } catch (e) { if (!(e instanceof AxiosError)) {