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('Connected to server ...');
|
||||||
console.log('Exporting ...');
|
console.log('Exporting ...');
|
||||||
try {
|
try {
|
||||||
const relativePdfDirectoryPath = '../pdf/';
|
const fullDirectoryPath = path.join(__dirname, '../pdf/');
|
||||||
const directories = getResumesFromDirectories();
|
const directories = getResumesFromDirectories();
|
||||||
directories.forEach(async (dir) => {
|
directories.forEach(async (dir) => {
|
||||||
const browser = await puppeteer.launch({
|
const browser = await puppeteer.launch({
|
||||||
@ -64,15 +64,12 @@ const convert = async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!fs.existsSync(path.join(__dirname, relativePdfDirectoryPath))
|
!fs.existsSync(fullDirectoryPath)
|
||||||
) {
|
) {
|
||||||
fs.mkdirSync(path.join(__dirname, relativePdfDirectoryPath));
|
fs.mkdirSync(fullDirectoryPath);
|
||||||
}
|
}
|
||||||
await page.pdf({
|
await page.pdf({
|
||||||
path: path.join(
|
path: fullDirectoryPath + dir.name + '.pdf',
|
||||||
__dirname,
|
|
||||||
relativePdfDirectoryPath + dir.name + '.pdf'
|
|
||||||
),
|
|
||||||
format: 'A4'
|
format: 'A4'
|
||||||
});
|
});
|
||||||
await browser.close();
|
await browser.close();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user