Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed May 22, 2024
2 parents 3180323 + 81ecd6a commit 4f6a9b1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ coverage.html
*.tgz
itest/
CITATION.cff
renovate.json
.rultor.yml
.pdd
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ choose from `craeted`, `updated` and `pushed`, the default one is `created`.
With `--batchsize 10` you can provide a batch-size value in the range from
10..100. The default value is `10`.

Also, with `--filename` you can provide the name of the file for the output CSV
and JSON files. The default one is `result`.
Also, with `--filename` you can provide the name of the file for the output
repos (CSV and JSON files). The default one is `result`. By default, it would
create `.csv` file only. In order to create `.json` too, just pass `--json`
option.

## How to contribute

Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const searchQuery = argv.query || '';
const startDate = argv.start || '2008-01-01';
const endDate = argv.end || now;
const dateType = argv.date || 'created';
const print = argv.json || false;

let tokens;
if (argv.tokens) {
if ('string' === typeof argv.tokens) {
Expand Down Expand Up @@ -251,8 +253,10 @@ function writeFiles(json) {
};
return data;
});
toJson(fileName, formattedResults);
toCsv(fileName, formattedResults);
if (print) {
toJson(fileName, formattedResults);
}
}

const countQuery = `query ($completeSearchQuery: String!) {
Expand Down
4 changes: 3 additions & 1 deletion test/to-json.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ const assert = require('assert');
describe('Test case for to-json.js', () => {
afterEach(
() => {
fs.unlinkSync('test.json');
if (fs.existsSync('test.json')) {
fs.unlinkSync('test.json');
}
}
);
it('creates .json file and writes results as JSON', function() {
Expand Down

0 comments on commit 4f6a9b1

Please sign in to comment.