diff --git a/src/command/game/index.js b/src/command/game/index.js index 7805132..863b50e 100644 --- a/src/command/game/index.js +++ b/src/command/game/index.js @@ -33,8 +33,14 @@ const getLosAngelesTimezone = date => .format(); const getSeason = date => { - const year = R.compose(getYear, parse)(date); - const month = R.compose(getMonth, parse)(date); + const year = R.compose( + getYear, + parse + )(date); + const month = R.compose( + getMonth, + parse + )(date); if (year < 2012 || (year === 2012 && month < 5)) { error( @@ -88,7 +94,12 @@ const game = async option => { let seasonMetaData; if (option.date) { - if (R.compose(isValid, parse)(option.date)) { + if ( + R.compose( + isValid, + parse + )(option.date) + ) { _date = format(option.date, 'YYYY-MM-DD'); } else { error('Date is invalid'); @@ -104,15 +115,24 @@ const game = async option => { error(`Can't find any option ${emoji.get('confused')}`); process.exit(1); } - R.compose(cfontsDate, getSeason)(_date); + R.compose( + cfontsDate, + getSeason + )(_date); const LADate = getLosAngelesTimezone(_date); try { const { - sports_content: { games: { game: _gamesData } }, + sports_content: { + games: { game: _gamesData }, + }, } = await NBA.getGamesFromDate(LADate); gamesData = _gamesData; + if (!gamesData.length) { + error('No game available on this date.'); + process.exit(1); + } } catch (err) { catchAPIError(err, 'NBA.getGamesFromDate()'); }