Chore: use native async fs.readFile in json-file-to-job-output script (#66686)

This commit is contained in:
Bruno 2023-04-24 09:46:56 -03:00 committed by GitHub
parent 2521fa9448
commit 86be40555f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,7 @@
module.exports = async ({ core, filePath }) => {
try {
const fs = require('fs');
const content = await readFile(fs, filePath);
const fs = require('fs').promises;
const content = await fs.readFile(filepath)
const result = JSON.parse(content);
core.startGroup('Parsing json file...');
@ -15,13 +15,4 @@ module.exports = async ({ core, filePath }) => {
} catch (error) {
core.restFailed(error.message);
}
}
async function readFile(fs, path) {
return new Promise((resolve, reject) => {
fs.readFile(path, (error, data) => {
if (error) return reject(error);
return resolve(data);
});
});
}