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: 2 additions & 2 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ require('yargs')
},
filetype: {
default: 'csv',
choices: ['csv', 'json', 'all', ''],
describe: "Type of the output file where the data will be saved. 'all' - save data to the 'json' and 'csv' files",
choices: ['csv', 'json', 'all', 'stdout', ''],
describe: "Type of the output file where the data will be saved. 'stdout' - print json to stdout. 'all' - save data to the 'json' and 'csv' files",
},
sort: {
default: false,
Expand Down
5 changes: 4 additions & 1 deletion lib/Amazon.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class AmazonScraper {
if (this.cli) {
spinner.stop();
}
if (this.fileType && this.cli) {
if (this.fileType && this.cli && this.fileType !== "stdout") {
console.log(`Result was saved to: ${this.fileName}`);
}
return {
Expand Down Expand Up @@ -310,6 +310,9 @@ class AmazonScraper {
async saveResultToFile() {
if (this.collector.length) {
switch (this.fileType) {
case 'stdout':
console.log(JSON.stringify(this.collector));
break;
case 'json':
await fromCallback((cb) => writeFile(`${this.fileName}.json`, JSON.stringify(this.collector), cb));
break;
Expand Down