Skip to content

Commit 573c52b

Browse files
authored
Merge pull request #2 from zcf0508/fix/fail_on_win
fix: run command fail on windows
2 parents e7311da + 456cb97 commit 573c52b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/utils.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as vscode from 'vscode';
2+
import * as path from 'path';
23
import { randomUUID } from 'crypto';
34
import { tmpdir } from 'os';
45
import { existsSync, readFileSync, unlinkSync, writeFileSync } from 'fs';
@@ -19,8 +20,8 @@ export async function getCommitMessage(
1920
) {
2021
const gptcommit = config.gptcommitPath || "gptcommit";
2122
const uid = randomUUID();
22-
const tmpMsgFile = `${tmpdir()}/vscode-gptcommit-${uid}.txt`;
23-
const tmpDiffFile = `${tmpdir()}/vscode-gptcommit-${uid}.diff`;
23+
const tmpMsgFile = path.join(tmpdir(), `vscode-gptcommit-${uid}.txt`);
24+
const tmpDiffFile = path.join(tmpdir(), `vscode-gptcommit-${uid}.diff`);
2425
const onFiles = config.onFiles || 'tryStagedThenUnstaged';
2526

2627
return vscode.window.withProgress({
@@ -44,7 +45,7 @@ export async function getCommitMessage(
4445
channel.appendLine(`COMMAND: ${cmd}`);
4546
return new Promise<string>((resolve, reject) => {
4647
exec(cmd, {
47-
cwd: repo.rootUri.path
48+
cwd: repo.rootUri.fsPath
4849
}, (err, stdout, stderr) => {
4950
channel.appendLine(`STDOUT: ${stdout}`);
5051
channel.appendLine(`STDERR: ${stderr}`);
@@ -58,7 +59,7 @@ export async function getCommitMessage(
5859
// set allow-amend to true
5960
const cmd = `${gptcommit} config set allow_amend true`;
6061
channel.appendLine(`COMMAND: ${cmd}`);
61-
execSync(cmd, {cwd: repo.rootUri.path});
62+
execSync(cmd, {cwd: repo.rootUri.fsPath});
6263
// try again
6364
getCommitMessage(config, repo, context, channel).then((msg) => {
6465
resolve(msg);

0 commit comments

Comments
 (0)