From 0c84148b5be1faa12821ffec72f965e647e3e61f Mon Sep 17 00:00:00 2001 From: Beer van der Drift Date: Mon, 1 Jul 2019 18:42:43 +0200 Subject: [PATCH] refactor: abstract absolute directory path in pdf gen into single const --- scripts/export.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/scripts/export.js b/scripts/export.js index fc64f6d..2a18da1 100755 --- a/scripts/export.js +++ b/scripts/export.js @@ -52,7 +52,7 @@ const convert = async () => { console.log('Connected to server ...'); console.log('Exporting ...'); try { - const relativePdfDirectoryPath = '../pdf/'; + const fullDirectoryPath = path.join(__dirname, '../pdf/'); const directories = getResumesFromDirectories(); directories.forEach(async (dir) => { const browser = await puppeteer.launch({ @@ -64,15 +64,12 @@ const convert = async () => { }); if ( - !fs.existsSync(path.join(__dirname, relativePdfDirectoryPath)) + !fs.existsSync(fullDirectoryPath) ) { - fs.mkdirSync(path.join(__dirname, relativePdfDirectoryPath)); + fs.mkdirSync(fullDirectoryPath); } await page.pdf({ - path: path.join( - __dirname, - relativePdfDirectoryPath + dir.name + '.pdf' - ), + path: fullDirectoryPath + dir.name + '.pdf', format: 'A4' }); await browser.close();