refactor: abstract absolute directory path in pdf gen into single const
This commit is contained in:
parent
d428f1ae29
commit
0c84148b5b
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user