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

refactor: drop external_link boolean type #5063

Merged
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
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 @@ -22,10 +22,5 @@ module.exports = ctx => {
if (config.root.trim().length <= 0) {
throw new TypeError('Invalid config detected: "root" should not be empty!');
}

// 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 @@ -100,13 +100,4 @@ describe('Validate config', () => {
e.message.should.eql('Invalid config detected: "root" should not be empty!');
}
});

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;
});
});