Display warning message only once

This commit is contained in:
Mimi 2023-06-05 17:21:56 +08:00
parent b9ba532df8
commit 824885ed0a

View File

@ -19,6 +19,12 @@ module.exports = hexo => {
if (typeof internal === 'function') {
internal(hexo, dependencies);
}
let { plugins = 'cdnjs' } = vendors;
if (plugins === 'local' && typeof internal === 'undefined') {
hexo.log.warn('Dependencies for `plugins: local` not found. The default CDN provider CDNJS is used instead.');
hexo.log.warn('Run `npm install @next-theme/plugins` in Hexo site root directory to install the plugin.');
plugins = 'cdnjs';
}
for (const [key, value] of Object.entries(dependencies)) {
// This script will be executed repeatedly when Hexo listens file changes
// But the variable vendors[key] only needs to be modified once
@ -41,12 +47,6 @@ module.exports = hexo => {
local : url_for.call(hexo, `lib/${name}/${file}`),
custom : vendors.custom_cdn_url
});
let { plugins = 'cdnjs' } = vendors;
if (plugins === 'local' && typeof internal === 'undefined') {
hexo.log.warn('Dependencies for `plugins: local` not found. The default CDN provider CDNJS is used instead.');
hexo.log.warn('Run `npm install @next-theme/plugins` in Hexo site root directory to install the plugin.');
plugins = 'cdnjs';
}
vendors[key] = {
url : links[plugins] || links.cdnjs,
integrity: value.integrity