import * as yaml from 'js-yaml' ; import { BotConfig , isBotConfig } from './models' ; /**
 * Parse the file according to the path into BotConfig
 */ export function parseConfig ( content ) { const data = yaml . safeLoad ( content ) ; if ( ! isBotConfig ( data ) ) { throw new Error ( 'invalid config' ) ; } else { return data ; } } export function shouldClose ( botConfig , content , senderName ) { if ( botConfig . exception && botConfig . exception . includes ( senderName ) ) { return false ; } return ! botConfig . issueConfigs . some ( ( issueConfig ) => { return issueConfig . content . every ( ( issueContent ) => { if ( botConfig . caseInsensitive ) { return content . toLowerCase ( ) . includes ( issueContent . toLowerCase ( ) ) ; } else { return content . includes ( issueContent ) ; } } ) ; } ) ; }