Skip to content

Commit e0648b8

Browse files
committed
fix: use env from cachedConfig when offlineEnv is set
This changeset modifies the `dev` command's behavior when the `--offlineEnv` command is set: Previously, passing `offlineEnv` would ignore any environment variable data from the cached configuration file by setting `env` data to an empty object before passing it around. The unintended consequence of this is that environment variable data set via the config file is ignored when running Preview Servers. Environment variable data is not passed to edge functions, and only build-time variables are passed to functions. With this change, we'll only default to an empty object when `cachedConfig.env` is not set. (I don't know if this is a realistic scenario, but I'm doing it this way to lower the risk of this change.)
1 parent efb5a3f commit e0648b8

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/commands/base-command.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -620,10 +620,7 @@ export default class BaseCommand extends Command {
620620
...apiUrlOpts,
621621
})
622622
const { accounts = [], buildDir, config, configPath, repositoryRoot, siteInfo } = cachedConfig
623-
let { env } = cachedConfig
624-
if (flags.offlineEnv) {
625-
env = {}
626-
}
623+
const env = cachedConfig?.env ?? {}
627624
env.NETLIFY_CLI_VERSION = { sources: ['internal'], value: version }
628625
const normalizedConfig = normalizeConfig(config)
629626

0 commit comments

Comments
 (0)