Skip to content

Commit

Permalink
Merge pull request #21 from DP6/exportChangeBowser
Browse files Browse the repository at this point in the history
feat: Export em txt, definindo xlsx como padrão e validando extensão …
  • Loading branch information
vandersonmaroni authored May 11, 2021
2 parents 9258798 + f9e9f2d commit f33f11c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ const config_file = process.argv.slice(2)[0]
'File not specified as start param. Please inform the filename with its extension as --file in start script.'
);

// Defining xlsx as default value.
let export_opt = 'xlsx';
let export_opt = process.argv.slice(2)[1] || 'xlsx';

// Checking command line params for export option
if (process.argv.slice(2)[1] === 'xlsx') {
export_opt = process.argv.slice(2)[1];
} else {
new Error('Export type not specified as start param. Please inform how you wish to export the results.');
} // For now, we can only export in xlsx, but later on we'll be able to export in pdf. Therefore, we'll leave this code line as is.
if (!(export_opt === 'xlsx' || export_opt === 'txt')) {
console.log(new Error('Export type not specified as start param. Please inform how you wish to export the results.'));
// For now, we can only export in xlsx and txt, but later on we'll be able to export in pdf. Therefore, we'll leave this code line as is.
return;
}

// Defining export extension based on export option extracted from command line params.
let filename = `${__dirname}/results/results_${new Date().getTime()}.${export_opt}`;
Expand Down

0 comments on commit f33f11c

Please sign in to comment.