Skip to content

Commit d7762cc

Browse files
committed
Fix a compile error
1 parent 88d7eaf commit d7762cc

5 files changed

Lines changed: 32 additions & 10 deletions

File tree

src/diagnostics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as vscode from "vscode";
22
import * as utils from "./utils";
3-
import * as path from "path";
3+
// ...existing code...
44
import getJiraDiagnostics from "./jira";
55

66
const preferSubjectLineLength = 50;
@@ -35,7 +35,7 @@ export function getDiagnostics(doc: vscode.TextDocument): vscode.Diagnostic[] {
3535
returnMe.push(...getSecondLineDiagnostic(secondLine));
3636
}
3737

38-
if (path.basename(doc.fileName) === "COMMIT_EDITMSG") {
38+
if (utils.basename(doc.fileName) === "COMMIT_EDITMSG") {
3939
returnMe.push(...getNoDiffDiagnostic(doc));
4040
}
4141

src/getgitbranch.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import * as vscode from "vscode";
22
import * as git from "./git";
3-
import * as path from "path";
43
import * as child_process from "child_process";
5-
import * as util from "util";
4+
import * as nodeUtil from "util";
5+
import * as utils from "./utils";
66

7-
const execFile = util.promisify(child_process.execFile);
7+
const execFile = nodeUtil.promisify(child_process.execFile);
88

99
export default async function getCurrentGitBranch(
1010
docUri: vscode.Uri,
@@ -65,7 +65,7 @@ async function getCurrentGitBranchFromGit(
6565
}
6666

6767
const docWithAbsolutePath = docUri.fsPath;
68-
const docDirectory = path.dirname(docWithAbsolutePath);
68+
const docDirectory = utils.dirname(docWithAbsolutePath);
6969

7070
try {
7171
const { stdout } = await execFile(

src/messages.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import * as vscode from "vscode";
2-
import * as path from "path";
32
import * as verbosecommits from "./verbosecommits";
3+
import * as utils from "./utils";
44

55
/** Show informational toast about doing verbose Git commits */
66
export async function displayVerboseDiffMessage(doc: vscode.TextDocument) {
7-
if (path.basename(doc.fileName) !== "COMMIT_EDITMSG") {
7+
if (utils.basename(doc.fileName) !== "COMMIT_EDITMSG") {
88
// We only like one kind of files
99
return;
1010
}

src/quickfix.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as vscode from "vscode";
2-
import * as path from "path";
32
import * as utils from "./utils";
43
import { gitBranch, setVerboseCommitCommandId } from "./extension";
54
import { createBranchIssueIdFix, createUpcaseJiraIdFix } from "./jira";
@@ -25,7 +24,7 @@ export default class GitCommitCodeActionProvider
2524
returnMe.push(...createBranchIssueIdFix(gitBranch, doc, range));
2625
returnMe.push(...createUpcaseJiraIdFix(doc, range));
2726

28-
if (path.basename(doc.fileName) === "COMMIT_EDITMSG") {
27+
if (utils.basename(doc.fileName) === "COMMIT_EDITMSG") {
2928
returnMe.push(...(await createEnableGitVerboseCommitFix(doc, range)));
3029
}
3130

src/utils.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,26 @@ export function getJiraIssueIdFromBranchName(
8989

9090
return undefined;
9191
}
92+
93+
/**
94+
* Returns the last portion of a path, handling both / and \ separators.
95+
* Equivalent to Node's path.basename, but works in browser and cross-platform.
96+
* @param filePath - The full file path.
97+
* @returns The file name portion of the path.
98+
*/
99+
export function basename(filePath: string): string {
100+
const parts = filePath.split(/[/]+/);
101+
return parts.pop() || "";
102+
}
103+
104+
/**
105+
* Returns the directory portion of a path, handling both / and \ separators.
106+
* Equivalent to Node's path.dirname, but works in browser and cross-platform.
107+
* @param filePath - The full file path.
108+
* @returns The directory portion of the path.
109+
*/
110+
export function dirname(filePath: string): string {
111+
const parts = filePath.split(/[/]+/);
112+
parts.pop();
113+
return parts.join("/");
114+
}

0 commit comments

Comments
 (0)