diff --git a/.npmignore b/.npmignore index b828ad9..6528475 100644 --- a/.npmignore +++ b/.npmignore @@ -8,3 +8,6 @@ coverage.html *.tgz itest/ CITATION.cff +renovate.json +.rultor.yml +.pdd diff --git a/README.md b/README.md index 5cb233b..2f60758 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/index.js b/src/index.js index 27b5ec6..ed3482a 100644 --- a/src/index.js +++ b/src/index.js @@ -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) { @@ -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!) { diff --git a/test/to-json.test.js b/test/to-json.test.js index 4342fc4..76c3479 100644 --- a/test/to-json.test.js +++ b/test/to-json.test.js @@ -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() {