Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for environment variables in HHVM debugger task #160

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Add a new HHVM `launch` config to `.vscode/launch.json`. The default template sh
`script`: The PHP/Hack script to launch. Use `${file}` to run the currently open file in the editor, or set to any other static file path.
`hhvmPath`: [Optional] Absolute path to the HHVM executable (default `hhvm`)
`hhvmArgs`: [Optional] Extra arguments to pass to HHVM when launching the script, if needed
`cwd`: [Optional] Working directory for the HHVM process
`cwd`: [Optional] Working directory for the HHVM process
`env`: [Optional] Extra environment variables for the HHVM process

Debug -> Start Debugging (F5) with this configuration selected will launch the currently open PHP/Hack script (or the custom configured file) in a new HHVM process and pipe input/output to the editor OUTPUT tab.

Expand Down
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@
"type": "string",
"description": "Working directory for the launched HHVM process",
"default": "${workspaceFolder}"
},
"env": {
"type": "object",
"description": "Extra environment variables for the HHVM command",
"additionalProperties": {
"type": "string"
},
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ interface HhvmLaunchRequestArguments
remoteType?: string;
remoteWorkspacePath?: string;
dockerContainerName?: string;
env?: Record<string, string>;
}

class HHVMDebuggerWrapper {
Expand Down Expand Up @@ -258,7 +259,7 @@ class HHVMDebuggerWrapper {
: ["pipe", "pipe", "pipe", "pipe"],
// When the wrapper exits, so does the target.
detached: false,
env: process.env,
env: { ...process.env, ...(args.env ?? {}) }
};

const targetProcess = child_process.spawn(hhvmPath, allArgs, options);
Expand Down Expand Up @@ -334,6 +335,7 @@ class HHVMDebuggerWrapper {
kind: "integrated",
cwd: __dirname,
args: terminalArgs,
env: { ...process.env, ...(args.env ?? {}) }
};

this.writeOutputWithHeader({
Expand Down