Chore: use native async fs.readFile in json-file-to-job-output script (#66686)
This commit is contained in:
@@ -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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user