Skip to content

Commit

Permalink
refactor: drop external_link boolean type
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshinorin committed Sep 17, 2022
1 parent 4d42d9d commit 8e8e005
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 68 deletions.
9 changes: 0 additions & 9 deletions lib/hexo/load_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const { exists, readdir } = require('hexo-fs');
const { magenta } = require('picocolors');
const { deepMerge } = require('hexo-util');
const validateConfig = require('./validate_config');
const { external_link: externalLinkDefaultCfg } = require('./default_config');

module.exports = async ctx => {
if (!ctx.env.init) return;
Expand Down Expand Up @@ -42,14 +41,6 @@ module.exports = async ctx => {
// Remove any trailing '/'
config.url = config.url.replace(/\/+$/, '');

// Deprecated: config.external_link boolean option will be removed in future
if (typeof config.external_link === 'boolean') {
config.external_link = {
...externalLinkDefaultCfg,
enable: config.external_link
};
}

ctx.public_dir = resolve(baseDir, config.public_dir) + sep;
ctx.source_dir = resolve(baseDir, config.source_dir) + sep;
ctx.source = new Source(ctx);
Expand Down
5 changes: 0 additions & 5 deletions lib/hexo/validate_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,5 @@ module.exports = ctx => {
if (typeof config.use_date_for_updated === 'boolean') {
log.warn('Deprecated config detected: "use_date_for_updated" is deprecated, please use "updated_option" instead. See https://hexo.io/docs/configuration for more details.');
}

// Soft deprecate external_link Boolean
if (typeof config.external_link === 'boolean') {
log.warn('Deprecated config detected: "external_link" with a Boolean value is deprecated. See https://hexo.io/docs/configuration for more details.');
}
};

45 changes: 0 additions & 45 deletions test/scripts/hexo/load_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,51 +127,6 @@ describe('Load config', () => {
}
});

// Deprecated: config.external_link boolean option will be removed in future
it('migrate external_link config from boolean to object - true', async () => {
const content = 'external_link: true';

try {
await writeFile(hexo.config_path, content);
await loadConfig(hexo);
hexo.config.external_link.should.eql({
enable: true,
field: 'site',
exclude: ''
});
} finally {
await unlink(hexo.config_path);
}
});

it('migrate external_link config from boolean to object - false', async () => {
const content = 'external_link: false';

try {
await writeFile(hexo.config_path, content);
await loadConfig(hexo);
hexo.config.external_link.should.eql({
enable: false,
field: 'site',
exclude: ''
});
} finally {
await unlink(hexo.config_path);
}
});

it('migrate external_link config from boolean to object - undefined', async () => {
try {
// Test undefined
await writeFile(hexo.config_path, '');

await loadConfig(hexo);
hexo.config.external_link.should.eql(defaultConfig.external_link);
} finally {
await unlink(hexo.config_path);
}
});

it('custom public_dir', async () => {
try {
await writeFile(hexo.config_path, 'public_dir: foo');
Expand Down
9 changes: 0 additions & 9 deletions test/scripts/hexo/validate_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,4 @@ describe('Validate config', () => {
logSpy.calledOnce.should.be.true;
logSpy.calledWith('Deprecated config detected: "use_date_for_updated" is deprecated, please use "updated_option" instead. See https://hexo.io/docs/configuration for more details.').should.be.true;
});

it('config.external_link - depreacte Boolean value', () => {
hexo.config.external_link = false;

validateConfig(hexo);

logSpy.calledOnce.should.be.true;
logSpy.calledWith('Deprecated config detected: "external_link" with a Boolean value is deprecated. See https://hexo.io/docs/configuration for more details.').should.be.true;
});
});

0 comments on commit 8e8e005

Please sign in to comment.