Skip to content

Commit

Permalink
feat: add flag to skip env var fetching (#6723)
Browse files Browse the repository at this point in the history
  • Loading branch information
davbree authored Jul 2, 2024
1 parent a265859 commit a0f33c1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/commands/base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,11 @@ export default class BaseCommand extends Command {
token,
...apiUrlOpts,
})
const { buildDir, config, configPath, env, repositoryRoot, siteInfo } = cachedConfig
const { buildDir, config, configPath, repositoryRoot, siteInfo } = cachedConfig
let { env } = cachedConfig
if (flags.offlineEnv) {
env = {}
}
env.NETLIFY_CLI_VERSION = { sources: ['internal'], value: version }
const normalizedConfig = normalizeConfig(config)

Expand Down Expand Up @@ -661,7 +665,10 @@ export default class BaseCommand extends Command {
// Configuration from netlify.[toml/yml]
config: normalizedConfig,
// Used to avoid calling @netlify/config again
cachedConfig,
cachedConfig: {
...cachedConfig,
env,
},
// global cli config
globalConfig,
// state of current site dir
Expand Down
5 changes: 4 additions & 1 deletion src/commands/dev/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const dev = async (options: OptionValues, command: BaseCommand) => {

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

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

2 comments on commit a0f33c1

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

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

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

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

Please sign in to comment.