* Run `profile create --merge --port [--env K=V ...]`. * Every entry in the merged env that was passed via userEnv (or * auto-applied by the CPU workaround) is forwarded as `--env`.
(env: NodeJS.ProcessEnv)
| 167 | * auto-applied by the CPU workaround) is forwarded as `--env`. |
| 168 | */ |
| 169 | private async configureProfile(env: NodeJS.ProcessEnv): Promise<void> { |
| 170 | this.logger.info(`[hindsight] configuring profile "${this.profile}"`); |
| 171 | |
| 172 | const [cmd, ...baseArgs] = getEmbedCommand({ |
| 173 | embedVersion: this.embedVersion, |
| 174 | embedPackagePath: this.embedPackagePath, |
| 175 | }); |
| 176 | const createArgs = [ |
| 177 | ...baseArgs, |
| 178 | "profile", |
| 179 | "create", |
| 180 | this.profile, |
| 181 | "--merge", |
| 182 | "--port", |
| 183 | String(this.port), |
| 184 | ]; |
| 185 | |
| 186 | // Forward every env var that the caller intended for the daemon as --env. |
| 187 | // We only forward keys the caller explicitly set (userEnv) plus the CPU |
| 188 | // workaround values — not the entire process.env, to avoid leaking random |
| 189 | // host state into profile config. |
| 190 | const envForProfile = this.collectProfileEnv(env); |
| 191 | for (const [key, value] of Object.entries(envForProfile)) { |
| 192 | createArgs.push("--env", `${key}=${value}`); |
| 193 | } |
| 194 | |
| 195 | createArgs.push(...this.extraProfileCreateArgs); |
| 196 | |
| 197 | await this.runCommand(cmd, createArgs, env, "profile.create"); |
| 198 | } |
| 199 | |
| 200 | /** Collect only the env vars that should be written into the profile file. */ |
| 201 | private collectProfileEnv(env: NodeJS.ProcessEnv): Record<string, string> { |
no test coverage detected