Replace uses of process.env.HOME with os.homedir() (#6479)
This commit is contained in:
@@ -1068,10 +1068,7 @@ function onShowRefCommand(arg?: TreeNode): void {
|
||||
function reportMacCrashes(): void {
|
||||
if (process.platform === "darwin") {
|
||||
prevCrashFile = "";
|
||||
const home: string | undefined = process.env.HOME;
|
||||
if (!home) {
|
||||
return;
|
||||
}
|
||||
const home: string = os.homedir();
|
||||
const crashFolder: string = path.resolve(home, "Library/Logs/DiagnosticReports");
|
||||
fs.stat(crashFolder, (err, stats) => {
|
||||
const crashObject: { [key: string]: string } = {};
|
||||
|
||||
@@ -126,10 +126,7 @@ export function getVcpkgPathDescriptorFile(): string {
|
||||
}
|
||||
return path.join(pathPrefix, "vcpkg/vcpkg.path.txt");
|
||||
} else {
|
||||
const pathPrefix: string | undefined = process.env.HOME;
|
||||
if (!pathPrefix) {
|
||||
throw new Error("Unable to read process.env.HOME");
|
||||
}
|
||||
const pathPrefix: string = os.homedir();
|
||||
return path.join(pathPrefix, ".vcpkg/vcpkg.path.txt");
|
||||
}
|
||||
}
|
||||
@@ -355,10 +352,7 @@ export function resolveVariables(input: string | undefined, additionalEnvironmen
|
||||
|
||||
// Resolve '~' at the start of the path.
|
||||
regexp = () => /^\~/g;
|
||||
ret = ret.replace(regexp(), (match: string, name: string) => {
|
||||
const newValue: string | undefined = (process.platform === 'win32') ? process.env.USERPROFILE : process.env.HOME;
|
||||
return newValue ? newValue : match;
|
||||
});
|
||||
ret = ret.replace(regexp(), (match: string, name: string) => os.homedir());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
* See 'LICENSE' in the project root for license information.
|
||||
* ------------------------------------------------------------------------------------------ */
|
||||
import * as assert from "assert";
|
||||
import * as os from "os";
|
||||
import { envDelimiter, resolveVariables, escapeForSquiggles } from "../../src/common";
|
||||
|
||||
suite("Common Utility validation", () => {
|
||||
suite("resolveVariables", () => {
|
||||
const success: string = "success";
|
||||
const home: string = process.env.HOME || process.env.USERPROFILE;
|
||||
const home: string = os.homedir();
|
||||
|
||||
test("raw input", () => {
|
||||
const input: string = "test";
|
||||
|
||||
Reference in New Issue
Block a user