Skip to content

Commit

Permalink
create a type guard for config mode
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskalmar committed Nov 18, 2023
1 parent a3934c4 commit f028b07
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,10 @@ export const MEDIA_UPLOAD_CONCURRENCY = 10;

export let config: Config;

export const detectConfigMode = (userConfig: Config) => {
if ('apiKey' in userConfig || 'lostPixelProjectId' in userConfig) {
return 'platform';
}

return 'generateOnly';
};
export const isPlatformModeConfig = (
userConfig: PlatformModeConfig | GenerateOnlyModeConfig,
): userConfig is PlatformModeConfig =>
'apiKey' in userConfig || 'lostPixelProjectId' in userConfig;

const printConfigErrors = (error: z.ZodError) => {
for (const issue of error.issues) {
Expand Down

0 comments on commit f028b07

Please sign in to comment.