Skip to content
This repository was archived by the owner on May 2, 2022. It is now read-only.

Commit de54b11

Browse files
authored
Report a plugin status (#85)
* Report a plugin status * Skip plugin status for local builds
1 parent e72abb9 commit de54b11

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/index.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ async function bundleFunctions(file, utils) {
110110
json({
111111
compact: true,
112112
}),
113-
terser()
113+
terser(),
114114
],
115115
onwarn(msg, warn) {
116116
if (msg.code == "UNRESOLVED_IMPORT") {
@@ -147,7 +147,7 @@ async function bundleFunctions(file, utils) {
147147
* @param {string} outputDir path to the output directory (created if not exists)
148148
* @param {boolean} isLocal whether we're running locally or in CI
149149
* @param {string | null} apiToken Netlify API token used for uploads
150-
* @returns {Promise<void>}
150+
* @returns {Promise<boolean>}
151151
*/
152152
async function publishBundle(bundle, handlers, outputDir, isLocal, apiToken) {
153153
// encode bundle into bytes
@@ -181,7 +181,10 @@ async function publishBundle(bundle, handlers, outputDir, isLocal, apiToken) {
181181
if (!uploaded) {
182182
console.log("Bundle already exists. Skipping upload...");
183183
}
184+
return uploaded;
184185
}
186+
187+
return false;
185188
}
186189

187190
function logHandlers(handlers, EDGE_HANDLERS_SRC) {
@@ -208,6 +211,18 @@ module.exports = {
208211

209212
logHandlers(handlers, EDGE_HANDLERS_SRC);
210213
const bundle = await bundleFunctions(mainFile, utils);
211-
await publishBundle(bundle, handlers, LOCAL_OUT_DIR, IS_LOCAL, NETLIFY_API_TOKEN);
214+
const uploaded = await publishBundle(bundle, handlers, LOCAL_OUT_DIR, IS_LOCAL, NETLIFY_API_TOKEN);
215+
216+
if (!IS_LOCAL) {
217+
const summaryText = uploaded
218+
? `${handlers.length} Edge Handlers deployed.`
219+
: `${handlers.length} Edge Handlers did not change.`;
220+
const logsLink = `https://app.netlify.com/sites/${process.env.SITE_NAME}/edge-handlers?scope=deployid:${process.env.DEPLOY_ID}`;
221+
222+
utils.status.show({
223+
title: "Edge Handlers",
224+
summary: `${summaryText} [Watch Logs](${logsLink})`,
225+
});
226+
}
212227
},
213228
};

0 commit comments

Comments
 (0)