Skip to content

Commit

Permalink
update type
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Sketon committed Oct 26, 2023
1 parent 1708be0 commit 30536c3
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 9 deletions.
5 changes: 3 additions & 2 deletions lib/box/file.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type Promise from 'bluebird';
import { readFile, readFileSync, stat, statSync, type ReadFileOptions } from 'hexo-fs';
import type fs from 'fs';

class File {
public source: string;
Expand All @@ -26,11 +27,11 @@ class File {
return readFileSync(this.source, options);
}

stat(): any {
stat(): Promise<fs.Stats> {
return stat(this.source);
}

statSync():any {
statSync(): fs.Stats {
return statSync(this.source);
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/console/list/category.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { underline } from 'picocolors';
import table from 'text-table';
import { stringLength } from './common';
import type Hexo from '../../../hexo';

function listCategory(): void {
function listCategory(this: Hexo): void {
const categories = this.model('Category');

const data = categories.sort({name: 1}).map(cate => [cate.name, String(cate.length)]);
Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/console/list/page.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { magenta, underline, gray } from 'picocolors';
import table from 'text-table';
import { stringLength } from './common';
import type Hexo from '../../../hexo';

function listPage(): void {
function listPage(this: Hexo): void {
const Page = this.model('Page');

const data = Page.sort({date: 1}).map(page => {
Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/console/list/post.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { gray, magenta, underline } from 'picocolors';
import table from 'text-table';
import { stringLength } from './common';
import type Hexo from '../../../hexo';

function mapName(item) {
return item.name;
}

function listPost(): void {
function listPost(this: Hexo): void {
const Post = this.model('Post');

const data = Post.sort({published: -1, date: 1}).map(post => {
Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/console/list/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import archy from 'archy';
import type Hexo from '../../../hexo';

function listRoute(): void {
function listRoute(this: Hexo): void {
const routes = this.route.list().sort();
const tree = buildTree(routes);
const nodes = buildNodes(tree);
Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/console/list/tag.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { magenta, underline } from 'picocolors';
import table from 'text-table';
import { stringLength } from './common';
import type Hexo from '../../../hexo';

function listTag(): void {
function listTag(this: Hexo): void {
const Tag = this.model('Tag');

const data = Tag.sort({name: 1}).map(tag => [tag.name, String(tag.length), magenta(tag.path)]);
Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/processor/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Pattern } from 'hexo-util';
import { magenta } from 'picocolors';
import type { _File } from '../../box';
import type Hexo from '../../hexo';
import type { Stats } from 'fs';

export = (ctx: Hexo) => {
return {
Expand Down Expand Up @@ -50,7 +51,7 @@ function processPage(ctx: Hexo, file: _File) {
return Promise.all([
file.stat(),
file.read()
]).spread((stats, content) => {
]).spread((stats: Stats, content: string | Buffer) => {
const data = yfm(content);
const output = ctx.render.getOutput(path);

Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/processor/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { slugize, Pattern, Permalink } from 'hexo-util';
import { magenta } from 'picocolors';
import type { _File } from '../../box';
import type Hexo from '../../hexo';
import type { Stats } from 'fs';

const postDir = '_posts/';
const draftDir = '_drafts/';
Expand Down Expand Up @@ -88,7 +89,7 @@ function processPost(ctx: Hexo, file: _File) {
return Promise.all([
file.stat(),
file.read()
]).spread((stats, content) => {
]).spread((stats: Stats, content: string | Buffer) => {
const data = yfm(content);
const info = parseFilename(config.new_post_name, path);
const keys = Object.keys(info);
Expand Down

0 comments on commit 30536c3

Please sign in to comment.