Skip to content

Commit

Permalink
fix: correct FilterFunction initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Feb 13, 2021
1 parent 72cc378 commit 1bf5ffb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
createLogFilter,
} from '../factories';
import type {
FilterFunction,
RoarrConfigurationType,
} from '../types';
import {
Expand Down Expand Up @@ -63,16 +64,16 @@ const argv = yargs

const roarrConfigurationPath = findNearestRoarrConfigurationPath();

let filterFunction = null;
let filterFunction: FilterFunction | null = null;

if (roarrConfigurationPath) {
/* eslint-disable node/global-require, import/no-dynamic-require, @typescript-eslint/no-var-requires */
const roarrConfiguration: RoarrConfigurationType = require(roarrConfigurationPath);

/* eslint-enable */

if (roarrConfiguration && roarrConfiguration['filter-function']) {
filterFunction = roarrConfiguration['filter-function'];
if (roarrConfiguration?.filterFunction) {
filterFunction = roarrConfiguration.filterFunction;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
MessageType,
} from 'roarr';

type FilterFunction = (message: MessageType) => boolean;
export type FilterFunction = (message: MessageType) => boolean;

export type RoarrConfigurationType = {
readonly filterFunction: FilterFunction,
Expand Down

0 comments on commit 1bf5ffb

Please sign in to comment.