mirror of
https://github.com/mattermost/mattermost.git
synced 2026-04-15 05:57:37 -04:00
* chore: upgrade cypress to 15.11 * update per comment * update flaky test (while here) --------- Co-authored-by: Mattermost Build <build@mattermost.com>
22 lines
678 B
JavaScript
22 lines
678 B
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
const fs = require('fs');
|
|
|
|
const {PDFParse} = require('pdf-parse');
|
|
|
|
/**
|
|
* Checks whether a file exist in the tests/downloads folder and return the content of it.
|
|
* @param {string} filePath - pdf file path
|
|
*/
|
|
module.exports = async (filePath) => {
|
|
const dataBuffer = fs.readFileSync(filePath);
|
|
const parser = new PDFParse({data: dataBuffer});
|
|
try {
|
|
const text = await parser.getText();
|
|
const info = await parser.getInfo();
|
|
return {text, info, numpages: info.numPages};
|
|
} finally {
|
|
await parser.destroy();
|
|
}
|
|
};
|