mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-18 18:33:42 +00:00
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
/* global hexo */
|
|
|
|
'use strict';
|
|
|
|
hexo.on('generateBefore', () => {
|
|
// Merge config.
|
|
require('./lib/config')(hexo);
|
|
// Add filter type `theme_inject`
|
|
require('./lib/injects')(hexo);
|
|
});
|
|
|
|
hexo.on('exit', () => {
|
|
if (!hexo.theme.config.reminder) return;
|
|
const https = require('https');
|
|
const path = require('path');
|
|
const { version } = require(path.normalize('../../package.json'));
|
|
https.get('https://registry.npmjs.org/hexo-theme-next/latest', {
|
|
headers: {
|
|
'User-Agent': 'Theme NexT Client'
|
|
}
|
|
}, res => {
|
|
let result = '';
|
|
res.on('data', data => {
|
|
result += data;
|
|
});
|
|
res.on('end', () => {
|
|
try {
|
|
const latest = JSON.parse(result).version;
|
|
if (latest !== version) {
|
|
hexo.log.warn(`Your theme NexT is outdated. Current version: v${version}, latest version: v${latest}`);
|
|
hexo.log.warn('Visit https://github.com/hexo-next/hexo-theme-next/releases for more information.');
|
|
} else {
|
|
hexo.log.info('Congratulations! Your are using the latest version of theme NexT.');
|
|
}
|
|
} catch (err) {
|
|
hexo.log.error('Failed to detect version info. Error message:');
|
|
hexo.log.error(err);
|
|
}
|
|
});
|
|
}).on('error', err => {
|
|
hexo.log.error('Failed to detect version info. Error message:');
|
|
hexo.log.error(err);
|
|
});
|
|
});
|