-
Notifications
You must be signed in to change notification settings - Fork 4
/
logResults.js
36 lines (30 loc) · 907 Bytes
/
logResults.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const logResults = (results, node, reporter) => {
let successfulEmbedsCount = 0;
let failedEmbedsCount = 0;
let unconformingEmbedsCount = 0;
let message = "";
for (const result of results) {
if (result instanceof Error) {
failedEmbedsCount++;
reporter.error(
`gatsby-remark-link-unfurl: Error embedding ${result.url}`,
result
);
} else if (result) {
successfulEmbedsCount++;
} else {
unconformingEmbedsCount++;
}
}
message += `gatsby-remark-link-unfurl:`;
message += ` Successful embeds: ${successfulEmbedsCount}`;
if (failedEmbedsCount > 0) {
message += ` | Failed embeds: ${failedEmbedsCount}`;
}
if (unconformingEmbedsCount > 0) {
message += ` | Links with no matching provider: ${unconformingEmbedsCount}`;
}
message += ` | Node: ${node.id}`;
reporter.info(message);
};
module.exports = logResults;