Skip to content

Commit

Permalink
Merge pull request #385 from EvanNotFound/dev
Browse files Browse the repository at this point in the history
feat: add NPMMirror CDN status logging and handling in welcome script
  • Loading branch information
EvanNotFound committed Jun 21, 2024
2 parents 18464e9 + a2ec6cb commit b22c187
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion scripts/events/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ hexo.on("ready", async () => {
hexo.locals.set(`cdnTestStatus_cdnjs`, 404);
hexo.locals.set(`cdnTestStatus_sustech`, 404);
hexo.locals.set(`cdnTestStatus_zstatic`, 404);
hexo.locals.set(`cdnTestStatus_npmMirror`, 404);
}
});

Expand Down Expand Up @@ -112,8 +113,19 @@ function checkVersionAndCDNAvailability(data) {
);
}

if (data.npmMirrorCDN) {
hexo.log.info(
`\x1b[32m%s\x1b[0m`,
`CDN available: NPMMirror (Recommended)`,
);
hexo.locals.set(`cdnTestStatus_npmMirror`, 200);
} else {
hexo.log.warn(`\x1b[31m%s\x1b[0m`, `NPMMirror CDN is unavailable yet.`);
hexo.locals.set(`cdnTestStatus_npmMirror`, 404);
}

if (data.zstaticCDN) {
hexo.log.info(`\x1b[32m%s\x1b[0m`, `CDN available: ZStatic (Recommended)`);
hexo.log.info(`\x1b[32m%s\x1b[0m`, `CDN available: ZStatic`);
hexo.locals.set(`cdnTestStatus_zstatic`, 200);
} else {
hexo.log.warn(`\x1b[31m%s\x1b[0m`, `ZStatic CDN is unavailable yet.`);
Expand Down

0 comments on commit b22c187

Please sign in to comment.