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: prepare for migration to typescript #5094

Merged
merged 4 commits into from
Dec 10, 2022
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
24 changes: 14 additions & 10 deletions lib/extend/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
'use strict';

exports.Console = require('./console');
exports.Deployer = require('./deployer');
exports.Filter = require('./filter');
exports.Generator = require('./generator');
exports.Helper = require('./helper');
exports.Injector = require('./injector');
exports.Migrator = require('./migrator');
exports.Processor = require('./processor');
exports.Renderer = require('./renderer');
exports.Tag = require('./tag');
const Console = require('./console');
const Deployer = require('./deployer');
const Filter = require('./filter');
const Generator = require('./generator');
const Helper = require('./helper');
const Injector = require('./injector');
const Migrator = require('./migrator');
const Processor = require('./processor');
const Renderer = require('./renderer');
const Tag = require('./tag');

module.exports = {
Console, Deployer, Filter, Generator, Helper, Injector, Migrator, Processor, Renderer, Tag
};
2 changes: 1 addition & 1 deletion lib/hexo/scaffold.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Scaffold {
if (!exist) return [];

return listDir(scaffoldDir, {
ignoreFilesRegex: /^_|\/_/
ignorePattern: /^_|\/_/
});
}).map(item => ({
name: item.substring(0, item.length - extname(item).length),
Expand Down
24 changes: 14 additions & 10 deletions lib/models/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
'use strict';

exports.Asset = require('./asset');
exports.Cache = require('./cache');
exports.Category = require('./category');
exports.Data = require('./data');
exports.Page = require('./page');
exports.Post = require('./post');
exports.PostAsset = require('./post_asset');
exports.PostCategory = require('./post_category');
exports.PostTag = require('./post_tag');
exports.Tag = require('./tag');
const Asset = require('./asset');
const Cache = require('./cache');
const Category = require('./category');
const Data = require('./data');
const Page = require('./page');
const Post = require('./post');
const PostAsset = require('./post_asset');
const PostCategory = require('./post_category');
const PostTag = require('./post_tag');
const Tag = require('./tag');

module.exports = {
Asset, Cache, Category, Data, Page, Post, PostAsset, PostCategory, PostTag, Tag
};
2 changes: 1 addition & 1 deletion lib/plugins/console/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class Generater {
// Check the public folder
return stat(publicDir).then(stats => {
if (!stats.isDirectory()) {
throw new Error('%s is not a directory', magenta(tildify(publicDir)));
throw new Error(`${magenta(tildify(publicDir))} is not a directory`);
}
}).catch(err => {
// Create public folder if not exists
Expand Down
11 changes: 6 additions & 5 deletions lib/plugins/console/list/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
'use strict';

const abbrev = require('abbrev');
const page = require('./page');
const post = require('./post');
const route = require('./route');
const tag = require('./tag');
const category = require('./category');

const store = {
page: require('./page'),
post: require('./post'),
route: require('./route'),
tag: require('./tag'),
category: require('./category')
page, post, route, tag, category
};

const alias = abbrev(Object.keys(store));
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/helper/number_format.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function numberFormatHelper(num, options = {}) {
const afterLast = after[precision];
const last = parseInt(after[precision - 1], 10);

afterResult = after.substring(0, precision - 1) + (afterLast < 5 ? last : last + 1);
afterResult = after.substring(0, precision - 1) + (Number(afterLast) < 5 ? last : last + 1);
} else {
afterResult = after;
for (let i = 0, len = precision - afterLength; i < len; i++) {
Expand All @@ -39,7 +39,7 @@ function numberFormatHelper(num, options = {}) {
}

after = afterResult;
} else if (precision === 0 || precision === '0') {
} else if (precision === 0) {
after = '';
}

Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/tag/img.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const rMeta = /["']?([^"']+)?["']?\s*["']?([^"']+)?["']?/;
*/
module.exports = ctx => {

return function imgTag(args, content) {
return function imgTag(args) {
const classes = [];
let src, width, height, title, alt;

Expand Down