Skip to content

Commit

Permalink
fix: filepath
Browse files Browse the repository at this point in the history
  • Loading branch information
uanid committed Jun 11, 2024
1 parent 6fa4982 commit e5bfbf6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
const config = resolvePluginConfig(userConfig, context);
Expand All @@ -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)) {
Expand All @@ -29,17 +31,16 @@ 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);
}

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)) {
Expand Down

0 comments on commit e5bfbf6

Please sign in to comment.