Skip to content

Commit 2f7ee91

Browse files
authored
Merge pull request #444 from PowerShell/daviwil/fix-pses-346
Don't send empty environment vars when not Windows PowerShell dev build
2 parents fd6f62f + 0866b10 commit 2f7ee91

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/session.ts

+17-4
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,23 @@ export class SessionManager {
254254
"-Command",
255255
"& '" + startScriptPath + "' " + startArgs);
256256

257+
// Set DEVPATH environment variable if necessary
258+
if (isWindowsDevBuild) {
259+
// The development build looks for this environment variable to
260+
// know where to find its assemblies
261+
process.env.DEVPATH = path.dirname(powerShellExePath);
262+
}
263+
else {
264+
// It's safe to delete this variable even if it doesn't exist
265+
delete process.env.DEVPATH;
266+
}
267+
257268
// Launch PowerShell as child process
258269
this.powerShellProcess =
259270
cp.spawn(
260271
powerShellExePath,
261272
powerShellArgs,
262-
{ env: isWindowsDevBuild ? { "DEVPATH": path.dirname(powerShellExePath) } : {} });
273+
{ env: process.env });
263274

264275
var decoder = new StringDecoder('utf8');
265276
this.powerShellProcess.stdout.on(
@@ -545,15 +556,17 @@ export class SessionManager {
545556
}
546557

547558
private resolvePowerShellPath(powerShellExePath: string): string {
559+
var resolvedPath = path.resolve(__dirname, powerShellExePath);
560+
548561
// If the path does not exist, show an error
549-
if (!utils.checkIfFileExists(powerShellExePath)) {
562+
if (!utils.checkIfFileExists(resolvedPath)) {
550563
this.setSessionFailure(
551-
"powershell.exe cannot be found or is not accessible at path " + powerShellExePath);
564+
"powershell.exe cannot be found or is not accessible at path " + resolvedPath);
552565

553566
return null;
554567
}
555568

556-
return powerShellExePath;
569+
return resolvedPath;
557570
}
558571

559572
private showSessionMenu() {

0 commit comments

Comments
 (0)