Skip to content

Commit

Permalink
refactor: utilize hexo-util
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Dec 10, 2019
1 parent e6e6d94 commit a6c6b84
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 4 additions & 2 deletions lib/hexo/load_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Theme = require('../theme');
const Source = require('./source');
const fs = require('hexo-fs');
const chalk = require('chalk');
const merge = require('deepmerge');
const { deepMerge } = require('hexo-util');

module.exports = ctx => {
if (!ctx.env.init) return;
Expand All @@ -26,7 +26,9 @@ module.exports = ctx => {

ctx.log.debug('Config loaded: %s', chalk.magenta(tildify(configPath)));

ctx.config = config = merge(ctx.config, config);
ctx.config = deepMerge(ctx.config, config);
config = ctx.config;

ctx.config_path = configPath;

config.root = config.root.replace(/\/*$/, '/');
Expand Down
6 changes: 3 additions & 3 deletions lib/hexo/multi_config_path.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const { isAbsolute, resolve, join, extname } = require('path');
const fs = require('hexo-fs');
const yml = require('js-yaml');
const merge = require('deepmerge');
const { deepMerge } = require('hexo-util');

module.exports = ctx => function multiConfigPath(base, configPaths, outputDir) {
const { log } = ctx;
Expand Down Expand Up @@ -48,10 +48,10 @@ module.exports = ctx => function multiConfigPath(base, configPaths, outputDir) {
const ext = extname(paths[i]).toLowerCase();

if (ext === '.yml') {
combinedConfig = merge(combinedConfig, yml.load(file));
combinedConfig = deepMerge(combinedConfig, yml.load(file));
count++;
} else if (ext === '.json') {
combinedConfig = merge(combinedConfig, yml.safeLoad(file, {json: true}));
combinedConfig = deepMerge(combinedConfig, yml.safeLoad(file, {json: true}));
count++;
} else {
log.w(`Config file ${paths[i]} not supported type.`);
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"bluebird": "^3.5.2",
"chalk": "^3.0.0",
"cheerio": "0.22.0",
"deepmerge": "^4.2.2",
"hexo-cli": "^3.0.0",
"hexo-front-matter": "^1.0.0",
"hexo-fs": "^2.0.0",
Expand Down

0 comments on commit a6c6b84

Please sign in to comment.