From 884d8bd1feb4df6fe9e9011a51904176bb4fc321 Mon Sep 17 00:00:00 2001 From: "Denise D." Date: Wed, 29 Jul 2026 15:10:25 +0200 Subject: [PATCH] minor changes --- file.js | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/file.js b/file.js index 3a46952..eb82a13 100644 --- a/file.js +++ b/file.js @@ -6,8 +6,6 @@ const os = require('os'); const path = require('path'); const sfdc = require('./sfdc2'); require('dotenv').config(); -let excelFile = process.argv[2]; -let pdfFile = process.argv[3]; // excel1 => /Users/ddatinguinoo/Downloads/Estratto IPP 5 Sic.xlsx // excel2 => /Users/ddatinguinoo/Downloads/Estratto Haccp IPP 5 (1).xlsx // excel3 di prova => /Users/ddatinguinoo/Downloads/File di prova.xlsx @@ -165,7 +163,6 @@ async function processPage(pdfDoc, pageIndex, tempFiles) { async function splitExcelFile(inputFile) { let numRows; // this parameter is needed when we need to analyze the pdf file in case it has duplicate pages const columnNames = []; // contains the names of the columns (header names) - const data = []; // contains the info of all the clients try { console.log(`Loading excel file: ${ inputFile }\n`); @@ -207,9 +204,8 @@ async function splitExcelFile(inputFile) { dataUser[cleanKey] = cell.value; }) - data.push(dataUser); } - return { numRows, data }; + return numRows; } catch (error) { console.error('Error processing the excel file: ', error); @@ -288,9 +284,10 @@ async function main() { if (isMyFlag) { console.log(`--- Test di attachPdfToAccount ${isDryRun ? '(MODALITÀ DRY RUN)' : ''} --- \n`); - const testPdfFile = pdfFile || process.argv[2]; + let excelFile = process.argv[2]; + let pdfFile = process.argv[3]; - if (!testPdfFile) { + if (!pdfFile || !excelFile) { console.error('Errore: Fornisci il percorso di un file PDF per il test.'); process.exit(1); } @@ -299,11 +296,9 @@ async function main() { try { let resultExcel = await splitExcelFile(excelFile); - let resultPdf = await splitPDF(resultExcel.numRows, pdfFile, tempFilePath); + let resultPdf = await splitPDF(resultExcel, pdfFile, tempFilePath); await initializeSalesforceConnection(); - - // Passiamo isDryRun come terzo parametro! await attachPdfToAccount(sfdc, resultPdf, isDryRun); } catch (err) { @@ -313,25 +308,6 @@ async function main() { } return; } - /*if (!excelFile || !pdfFile) { - console.error('Error: Please provide both Excel and PDF paths.\nUsage: node script.js '); - process.exit(1); - } - - const tempFilePath = []; // contains the temporary files - let resultExcel, resultPdf; - try { - resultExcel = await splitExcelFile(excelFile); - resultPdf = await splitPDF(resultExcel.numRows, pdfFile, tempFilePath); - await initializeSalesforceConnection(); - await attachPdfToAccount(sfdc, resultPdf); - } - catch (err) { - console.error('An error occurred in main: ', err); - } - finally { - cleanUp(tempFilePath); - }*/ } main(); \ No newline at end of file