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
@@ -1,7 +1,7 @@
module.exports = async ({ core, filePath }) => { module.exports = async ({ core, filePath }) => {
try { try {
const fs = require('fs'); const fs = require('fs').promises;
const content = await readFile(fs, filePath); const content = await fs.readFile(filepath)
const result = JSON.parse(content); const result = JSON.parse(content);
core.startGroup('Parsing json file...'); core.startGroup('Parsing json file...');
@@ -15,13 +15,4 @@ module.exports = async ({ core, filePath }) => {
} catch (error) { } catch (error) {
core.restFailed(error.message); 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);
});
});
} }