-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: respect no-auto-updates flag in cli config
- Loading branch information
1 parent
f53cd0e
commit 26dd321
Showing
3 changed files
with
32 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/sanity/src/_internal/cli/util/shouldAutoUpdate.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {type CliConfig} from '@sanity/cli' | ||
|
||
import {type BuildSanityStudioCommandFlags} from '../actions/build/buildAction' | ||
|
||
interface AutoUpdateSources { | ||
flags: BuildSanityStudioCommandFlags | ||
cliConfig?: CliConfig | ||
} | ||
|
||
/** | ||
* Compares parameters from various sources to determine whether or not to auto-update | ||
* @param sources - The sources of the auto-update parameter, including CLI flags and the CLI config | ||
* @returns boolean | ||
* @internal | ||
*/ | ||
export function shouldAutoUpdate({flags, cliConfig}: AutoUpdateSources): boolean { | ||
// cli flags (for example, '--no-auto-updates') should take precedence | ||
if ('auto-updates' in flags) { | ||
return Boolean(flags['auto-updates']) | ||
} | ||
|
||
if (cliConfig && 'autoUpdates' in cliConfig) { | ||
return Boolean(cliConfig.autoUpdates) | ||
} | ||
|
||
return false | ||
} |