Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace lodash with native API #1230

Merged
merged 5 commits into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/events/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ hexo.on('generateAfter', () => {
if (!hexo.theme.config.reminder) return;
const https = require('https');
const path = require('path');
const env = require(path.normalize('../../package.json'));
const { version } = require(path.normalize('../../package.json'));
https.get({
hostname: 'api.github.com',
port : 443,
Expand All @@ -30,7 +30,7 @@ hexo.on('generateAfter', () => {
res.on('end', () => {
try {
var latest = JSON.parse(result).tag_name.replace('v', '').split('.');
var current = env.version.split('.');
var current = version.split('.');
var isOutdated = false;
for (var i = 0; i < Math.max(latest.length, current.length); i++) {
if (!current[i] || latest[i] > current[i]) {
Expand Down
17 changes: 15 additions & 2 deletions scripts/events/lib/config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
'use strict';

function isObject(item) {
return item && typeof item === 'object' && !Array.isArray(item);
}

function merge(target, source) {
for (const key in source) {
if (isObject(target[key]) && isObject(source[key])) {
merge(target[key], source[key]);
} else {
target[key] = source[key];
}
}
return target;
}

module.exports = hexo => {
if (!hexo.locals.get) return;

var data = hexo.locals.get('data');
if (!data) return;

const merge = require(hexo.base_dir + 'node_modules/lodash/merge');

/**
* Merge configs from _data/next.yml into hexo.theme.config.
* If `override`, configs in next.yml will rewrite configs in hexo.theme.config.
Expand Down