Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7bcbea6

Browse files
authored
Replace uses of process.env.HOME with os.homedir() (microsoft#6479)
1 parentec66642 commit7bcbea6

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

‎Extension/src/LanguageServer/extension.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,10 +1068,7 @@ function onShowRefCommand(arg?: TreeNode): void {
10681068
functionreportMacCrashes():void{
10691069
if(process.platform==="darwin"){
10701070
prevCrashFile="";
1071-
consthome:string|undefined=process.env.HOME;
1072-
if(!home){
1073-
return;
1074-
}
1071+
consthome:string=os.homedir();
10751072
constcrashFolder:string=path.resolve(home,"Library/Logs/DiagnosticReports");
10761073
fs.stat(crashFolder,(err,stats)=>{
10771074
constcrashObject:{[key:string]:string}={};

‎Extension/src/common.ts‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,7 @@ export function getVcpkgPathDescriptorFile(): string {
126126
}
127127
returnpath.join(pathPrefix,"vcpkg/vcpkg.path.txt");
128128
}else{
129-
constpathPrefix:string|undefined=process.env.HOME;
130-
if(!pathPrefix){
131-
thrownewError("Unable to read process.env.HOME");
132-
}
129+
constpathPrefix:string=os.homedir();
133130
returnpath.join(pathPrefix,".vcpkg/vcpkg.path.txt");
134131
}
135132
}
@@ -355,10 +352,7 @@ export function resolveVariables(input: string | undefined, additionalEnvironmen
355352

356353
// Resolve '~' at the start of the path.
357354
regexp=()=>/^\~/g;
358-
ret=ret.replace(regexp(),(match:string,name:string)=>{
359-
constnewValue:string|undefined=(process.platform==='win32') ?process.env.USERPROFILE :process.env.HOME;
360-
returnnewValue ?newValue :match;
361-
});
355+
ret=ret.replace(regexp(),(match:string,name:string)=>os.homedir());
362356

363357
returnret;
364358
}

‎Extension/test/unitTests/common.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
* See 'LICENSE' in the project root for license information.
44
* ------------------------------------------------------------------------------------------ */
55
import*asassertfrom"assert";
6+
import*asosfrom"os";
67
import{envDelimiter,resolveVariables,escapeForSquiggles}from"../../src/common";
78

89
suite("Common Utility validation",()=>{
910
suite("resolveVariables",()=>{
1011
constsuccess:string="success";
11-
consthome:string=process.env.HOME||process.env.USERPROFILE;
12+
consthome:string=os.homedir();
1213

1314
test("raw input",()=>{
1415
constinput:string="test";

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp