Skip to content

Commit

Permalink
fix: retain original process env when call spawn helper (#6301)
Browse files Browse the repository at this point in the history
* fix: retain original process env when call `spawn` helper

Co-authored-by: Steffen Neubauer <[email protected]>

* refactor: weaken the type definitions for envs

Co-authored-by: Steffen Neubauer <[email protected]>

---------

Co-authored-by: Steffen Neubauer <[email protected]>
  • Loading branch information
vvagaytsev and stefreak authored Jul 18, 2024
1 parent 9e1ac29 commit 593b3e4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions core/src/plugins/container/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import type { Resolved } from "../../actions/types.js"
import pMemoize from "../../lib/p-memoize.js"
import { styles } from "../../logger/styles.js"
import type { ContainerProviderConfig } from "./container.js"
import { type MaybeSecret } from "../../util/secrets.js"
import type { MaybeSecret } from "../../util/secrets.js"

const { readFile, pathExists, lstat } = fsExtra

Expand Down Expand Up @@ -393,7 +393,7 @@ const helpers = {
stdout?: Writable
stderr?: Writable
timeout?: number
env?: { [key: string]: MaybeSecret }
env?: Record<string, MaybeSecret | undefined>
}) {
const docker = ctx.tools["container.docker"]

Expand Down
12 changes: 6 additions & 6 deletions core/src/util/ext-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
*/

import fsExtra from "fs-extra"
const { pathExists, createWriteStream, ensureDir, chmod, remove, move, createReadStream } = fsExtra
import { InternalError } from "../exceptions.js"
import { join, dirname, basename, posix } from "path"
import { basename, dirname, join, posix } from "path"
import { getArchitecture, getPlatform, isDarwinARM } from "./arch-platform.js"
import { hashString, exec, prepareClearTextEnv } from "./util.js"
import { exec, hashString, prepareClearTextEnv, spawn } from "./util.js"
import tar from "tar"
import { GARDEN_GLOBAL_PATH } from "../constants.js"
import type { Log } from "../logger/log-entry.js"
import { createHash } from "node:crypto"
import crossSpawn from "cross-spawn"
import { spawn } from "./util.js"
import type { Writable } from "stream"
import got from "got"
import type { PluginToolSpec, ToolBuildSpec } from "../plugin/tools.js"
Expand All @@ -28,15 +26,17 @@ import { LogLevel } from "../logger/logger.js"
import { uuidv4 } from "./random.js"
import { streamLogs, waitForProcess } from "./process.js"
import { pipeline } from "node:stream/promises"
import { type MaybeSecret } from "./secrets.js"
import type { MaybeSecret } from "./secrets.js"

const { pathExists, createWriteStream, ensureDir, chmod, remove, move, createReadStream } = fsExtra

const toolsPath = join(GARDEN_GLOBAL_PATH, "tools")
const lock = new AsyncLock()

export interface ExecParams {
args?: string[]
cwd?: string
env?: { [key: string]: MaybeSecret }
env?: Record<string, MaybeSecret | undefined>
log: Log
timeoutSec?: number
input?: Buffer | string
Expand Down
3 changes: 2 additions & 1 deletion core/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ export function prepareClearTextEnv(env: Record<string, MaybeSecret | undefined>
: {}

return toClearText({
...(env || process.env),
...process.env,
...(env || {}),
...envOverride,
})
}
Expand Down

0 comments on commit 593b3e4

Please sign in to comment.