Skip to content

Commit

Permalink
feat: Export em txt, definindo xlsx como padrão e validando extensão …
Browse files Browse the repository at this point in the history
…indisponível

Passar txt ou xlsx como último parâmetro na linha de comando, se nada for passado, o arquivo será exportado em xlsx como padão e se for passado algum valor que não seja nem xlsx nem txt será exibida uma mensagem de erro e a execução será interrompida.
  • Loading branch information
ghusta-fernandes committed Apr 16, 2021
1 parent ced86e8 commit ffb118d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ 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 txt 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 if (process.argv.slice(2)[1] === 'pdf') {
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.');
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.
Expand Down

0 comments on commit ffb118d

Please sign in to comment.