Skip to content

Commit

Permalink
fix: throw error when running in CI if there is missing required conf…
Browse files Browse the repository at this point in the history
…iguration
  • Loading branch information
tagoro9 committed Dec 20, 2022
1 parent e9f6a92 commit 15c8edb
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/cli/FotingoCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,27 @@ export abstract class FotingoCommand<T, R> extends Command {

/**
* Ask the user for the required configurations that are currently missing and write them to the closest config
* file
* file. If running in CI, throw an error instead
*/
private askForRequiredConfig(config: Config): Observable<Partial<Config>> {
// TODO requiredConfig should be configurable by each command
return from(requiredConfigs.filter((cfg) => path(cfg.path, config) === undefined)).pipe(
const missingConfig$ = from(
requiredConfigs.filter((cfg) => path(cfg.path, config) === undefined),
);
if (this.isCi) {
return missingConfig$.pipe(
reduce((accumulator: string[], current) => [...accumulator, current.path.join('.')], []),
switchMap((configurations) => {
if (configurations.length === 0) {
return of({});
}
return throwError(
() => new Error(`Missing required configuration: ${configurations.join(', ')}`),
);
}),
);
}
return missingConfig$.pipe(
concatMap((requiredConfig) =>
this.messenger
.request(requiredConfig.request)
Expand Down

0 comments on commit 15c8edb

Please sign in to comment.