Skip to content

Commit

Permalink
style: fix lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
OpportunityLiu committed Feb 5, 2025
1 parent c3b75da commit 3470070
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/server/database/database.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ export class DatabaseService extends InjectableBase implements OnModuleInit {
let updatedFiles: string[];
if (oldInfo.head.sha.length !== 40) {
updatedFiles = await Promise.all(
['version', ...NamespaceName.map((ns) => `database/${ns}.md`)].map((f) => pullFile(f)),
['version', ...NamespaceName.map((ns) => `database/${ns}.md`)].map(async (f) => pullFile(f)),
);
this.logger.verbose(`Reconstruction of database. Updated files: ${updatedFiles.join(', ')}`);
} else {
const comparison = await this.octokit.compare(this.info.head.sha, headCommit.sha);
if (comparison.files && comparison.files.length > 0) {
updatedFiles = await Promise.all(
comparison.files.map((f) => pullFile(f.filename, f.status === 'removed')),
comparison.files.map(async (f) => pullFile(f.filename, f.status === 'removed')),
);
} else {
updatedFiles = [];
Expand All @@ -143,8 +143,8 @@ export class DatabaseService extends InjectableBase implements OnModuleInit {
): Promise<void> {
const content = await this.data.data[ns].save();
let msg: string;
const oldContext = new Context((message.ov ?? message.nv) as TagRecord, message.ok);
const newContext = new Context((message.nv ?? message.ov) as TagRecord, message.nk);
const oldContext = new Context((message.ov ?? message.nv)!, message.ok);
const newContext = new Context((message.nv ?? message.ov)!, message.nk);
if (message.ov && message.nv) {
msg = `修改 ${ns}:${message.nk ?? message.ok ?? '(注释)'} - ${message.nv.name.render('text', newContext)}
| | 原始标签 | 名称 | 描述 | 外部链接 |
Expand Down Expand Up @@ -181,5 +181,5 @@ ${message.nv.stringify(newContext)}
readonly path: string;
readonly repo: string;

public data!: Database;
data!: Database;
}
10 changes: 6 additions & 4 deletions src/server/octokit/octokit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ export class OctokitService extends InjectableBase implements OnModuleInit {
else throw new Error(`Failed to get app info`);
});
this._botUserInfo = this._appInfo
.then((appInfo) => this.forApp.users.getByUsername({ username: `${appInfo.slug ?? appInfo.name}[bot]` }))
.then(async (appInfo) =>
this.forApp.users.getByUsername({ username: `${appInfo.slug ?? appInfo.name}[bot]` }),
)
.then((userInfoReq) => Object.freeze(userInfoReq.data));
}

Expand Down Expand Up @@ -157,7 +159,7 @@ export class OctokitService extends InjectableBase implements OnModuleInit {
repo: this.repo,
path,
});
const data = res.data;
const { data } = res;
if (Array.isArray(data) || data.type !== 'file' || !('encoding' in data)) {
throw new Error(`${path} is not a file.`);
}
Expand Down Expand Up @@ -187,7 +189,7 @@ export class OctokitService extends InjectableBase implements OnModuleInit {
sha: oldSha,
author,
});
const data = res.data;
const { data } = res;
return {
file: {
path: data.content?.path ?? path,
Expand All @@ -211,7 +213,7 @@ export class OctokitService extends InjectableBase implements OnModuleInit {
repo: this.repo,
branch: 'master',
});
const commit = res.data.commit;
const { commit } = res.data;
return {
sha: commit.sha as Sha1Value,
message: commit.commit.message,
Expand Down

0 comments on commit 3470070

Please sign in to comment.