Skip to content

Commit 4ae30e0

Browse files
change to home folder
1 parent 8be964e commit 4ae30e0

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/commands/show.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use strict";
22

3+
import * as fse from "fs-extra";
34
import * as vscode from "vscode";
45
import { LeetCodeNode } from "../leetCodeExplorer";
56
import { leetCodeManager } from "../leetCodeManager";
@@ -41,6 +42,7 @@ async function showProblemInternal(id: string): Promise<void> {
4142
return;
4243
}
4344
const outdir: string = await selectWorkspaceFolder();
45+
await fse.ensureDir(outdir);
4446
const result: string = await executeCommand("node", [leetCodeBinaryPath, "show", id, "-gx", "-l", language, "-o", outdir]);
4547
const reg: RegExp = /\* Source Code:\s*(.*)/;
4648
const match: RegExpMatchArray | null = result.match(reg);

src/commands/submit.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export async function submitSolution(): Promise<void> {
2525
const filePath: string = textEditor.document.uri.fsPath;
2626
try {
2727
const result: string = await executeCommand("node", [leetCodeBinaryPath, "submit", filePath]);
28-
const resultPath: string = path.join(os.tmpdir(), "Result");
28+
const resultPath: string = path.join(os.homedir(), ".leetcode", "Result");
2929
await fse.ensureFile(resultPath);
3030
await fse.writeFile(resultPath, result);
3131
await vscode.window.showTextDocument(vscode.Uri.file(resultPath));

src/utils/workspaceUtils.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict";
22

33
import * as os from "os";
4+
import * as path from "path";
45
import * as vscode from "vscode";
56

67
export async function selectWorkspaceFolder(): Promise<string> {
@@ -14,5 +15,5 @@ export async function selectWorkspaceFolder(): Promise<string> {
1415
folder = vscode.workspace.workspaceFolders[0];
1516
}
1617
}
17-
return folder ? folder.uri.fsPath : os.tmpdir();
18+
return folder ? folder.uri.fsPath : path.join(os.homedir(), ".leetcode");
1819
}

0 commit comments

Comments
 (0)