Skip to content

Commit a0f33c1

Browse files
authoredJul 2, 2024··
feat: add flag to skip env var fetching (#6723)
1 parent a265859 commit a0f33c1

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed
 

‎src/commands/base-command.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,11 @@ export default class BaseCommand extends Command {
596596
token,
597597
...apiUrlOpts,
598598
})
599-
const { buildDir, config, configPath, env, repositoryRoot, siteInfo } = cachedConfig
599+
const { buildDir, config, configPath, repositoryRoot, siteInfo } = cachedConfig
600+
let { env } = cachedConfig
601+
if (flags.offlineEnv) {
602+
env = {}
603+
}
600604
env.NETLIFY_CLI_VERSION = { sources: ['internal'], value: version }
601605
const normalizedConfig = normalizeConfig(config)
602606

@@ -661,7 +665,10 @@ export default class BaseCommand extends Command {
661665
// Configuration from netlify.[toml/yml]
662666
config: normalizedConfig,
663667
// Used to avoid calling @netlify/config again
664-
cachedConfig,
668+
cachedConfig: {
669+
...cachedConfig,
670+
env,
671+
},
665672
// global cli config
666673
globalConfig,
667674
// state of current site dir

‎src/commands/dev/dev.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export const dev = async (options: OptionValues, command: BaseCommand) => {
118118

119119
env[BLOBS_CONTEXT_VARIABLE] = { sources: ['internal'], value: encodeBlobsContext(blobsContext) }
120120

121-
if (!options.offline) {
121+
if (!options.offline && !options.offlineEnv) {
122122
env = await getEnvelopeEnv({ api, context: options.context, env, siteInfo })
123123
log(`${NETLIFYDEVLOG} Injecting environment variable values for ${chalk.yellow('all scopes')}`)
124124
}
@@ -275,6 +275,9 @@ export const createDevCommand = (program: BaseCommand) => {
275275
.option('-d ,--dir <path>', 'dir with static files')
276276
.option('-f ,--functions <folder>', 'specify a functions folder to serve')
277277
.option('-o ,--offline', 'disables any features that require network access')
278+
.addOption(
279+
new Option('--offline-env', 'disables fetching environment variables from the Netlify API').hideHelp(true),
280+
)
278281
.addOption(
279282
new Option(
280283
'--internal-disable-edge-functions',

2 commit comments

Comments
 (2)

github-actions[bot] commented on Jul 2, 2024

@github-actions[bot]

📊 Benchmark results

  • Dependency count: 1,212
  • Package size: 313 MB
  • Number of ts-expect-error directives: 976

github-actions[bot] commented on Jul 2, 2024

@github-actions[bot]

📊 Benchmark results

  • Dependency count: 1,212
  • Package size: 313 MB
  • Number of ts-expect-error directives: 976
Please sign in to comment.