Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
refactor: utilize hexo-util
  • Loading branch information
SukkaW committed Dec 7, 2019
1 parent 43b40cd commit 5b38c4f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions lib/hexo/load_config.js
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
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
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -50,7 +50,7 @@
"hexo-fs": "^2.0.0",
"hexo-i18n": "^1.0.0",
"hexo-log": "^1.0.0",
"hexo-util": "^1.5.0",
"hexo-util": "github:hexojs/hexo-util#master",
"js-yaml": "^3.12.0",
"lodash": "^4.17.11",
"micromatch": "^4.0.2",
Expand Down

0 comments on commit 5b38c4f

Please sign in to comment.