Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ cache:
directories:
- $HOME/.npm
script:
- npm run lint
- npm link
- npm run test
- npm run lint
19 changes: 19 additions & 0 deletions __tests__/lists.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint-env jest */

const fs = require('fs');
const syncExec = require('sync-exec');
const commandExistsSync = require('command-exists').sync;

const COMMAND = 'football';

beforeEach(() => {
if (!commandExistsSync(COMMAND)) {
throw new Error(`Command "${COMMAND}" command not found`);
}
});

describe('football lists', () => {
it('should show lists', () => {
syncExec('football lists');
});
});
6 changes: 5 additions & 1 deletion cmds/lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ const Table = require('cli-table3');
const chalk = require('chalk');
const leagueIds = require('../leagueIds');
const helpers = require('./utils/helpers');
const logging = require('./utils/logging');
const URLS = require('../constants');

const { updateMessage } = helpers;
const { getLogger } = logging;
const { LEAGUE_IDS_URL } = URLS;

const log = getLogger();

exports.command = 'lists';
exports.desc = 'List of codes of various competitions';

Expand Down Expand Up @@ -69,6 +73,6 @@ exports.handler = function handler(yargs) {
}

spinner.stop();
console.log(table.toString());
log(table.toString());
}
};
13 changes: 13 additions & 0 deletions cmds/utils/logging.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const fs = require('fs');

const getLogger = () => {
if (process.env.NODE_ENV === 'test') {
const logs = fs.createWriteStream('/var/log/football-tests.log', { flags: 'w' });
return log => logs.write(`${log}\n`);
}
return console.log;
};

module.exports = {
getLogger
};
Loading