Skip to content

Commit 0813b6d

Browse files
committed
Rename isLocalUpdate to forceUpdate
1 parent 4d79ea3 commit 0813b6d

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

src/commands/pull.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ export const pull = async (argv: string[]) => {
1414

1515
const qiitaApi = await getQiitaApiInstance();
1616
const fileSystemRepo = await getFileSystemRepo();
17-
const isLocalUpdate = args["--force"];
17+
const forceUpdate = args["--force"];
1818

19-
await syncArticlesFromQiita({ fileSystemRepo, qiitaApi, isLocalUpdate });
19+
await syncArticlesFromQiita({ fileSystemRepo, qiitaApi, forceUpdate });
2020
console.log("Sync local articles from Qiita");
2121
console.log("Successful!");
2222
};

src/lib/file-system-repo.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,9 @@ updated
315315
`;
316316
const subject = (
317317
beforeSync: boolean = false,
318-
isLocalUpdate: boolean = false
318+
forceUpdate: boolean = false
319319
) => {
320-
return instance.saveItem(item, beforeSync, isLocalUpdate);
320+
return instance.saveItem(item, beforeSync, forceUpdate);
321321
};
322322

323323
describe("when local article does not exist", () => {
@@ -378,7 +378,7 @@ updated
378378
});
379379
});
380380

381-
describe("when isLocalUpdate is true", () => {
381+
describe("when forceUpdate is true", () => {
382382
it("saves item local and remote", () => {
383383
const mockFs = fs as jest.Mocked<typeof fs>;
384384
mockFs.readdir.mockResolvedValueOnce([localFilename] as any[]);

src/lib/file-system-repo.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ export class FileSystemRepo {
264264
private async syncItem(
265265
item: Item,
266266
beforeSync: boolean = false,
267-
isLocalUpdate: boolean = false
267+
forceUpdate: boolean = false
268268
) {
269269
const fileContent = FileContent.fromItem(item);
270270

@@ -279,17 +279,17 @@ export class FileSystemRepo {
279279
true
280280
);
281281

282-
if (data === null || remoteFileContent?.equals(data) || isLocalUpdate) {
282+
if (data === null || remoteFileContent?.equals(data) || forceUpdate) {
283283
await this.setItemData(fileContent, true);
284284
await this.setItemData(fileContent, false, basename);
285285
} else {
286286
await this.setItemData(fileContent, true);
287287
}
288288
}
289289

290-
async saveItems(items: Item[], isLocalUpdate: boolean = false) {
290+
async saveItems(items: Item[], forceUpdate: boolean = false) {
291291
const promises = items.map(async (item) => {
292-
await this.syncItem(item, false, isLocalUpdate);
292+
await this.syncItem(item, false, forceUpdate);
293293
});
294294

295295
await Promise.all(promises);
@@ -298,9 +298,9 @@ export class FileSystemRepo {
298298
async saveItem(
299299
item: Item,
300300
beforeSync: boolean = false,
301-
isLocalUpdate: boolean = false
301+
forceUpdate: boolean = false
302302
) {
303-
await this.syncItem(item, beforeSync, isLocalUpdate);
303+
await this.syncItem(item, beforeSync, forceUpdate);
304304
}
305305

306306
async loadItems(): Promise<QiitaItem[]> {

src/lib/sync-articles-from-qiita.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import { config } from "./config";
55
export const syncArticlesFromQiita = async ({
66
fileSystemRepo,
77
qiitaApi,
8-
isLocalUpdate = false,
8+
forceUpdate = false,
99
}: {
1010
fileSystemRepo: FileSystemRepo;
1111
qiitaApi: QiitaApi;
12-
isLocalUpdate?: boolean;
12+
forceUpdate?: boolean;
1313
}) => {
1414
const per = 100;
1515
const userConfig = await config.getUserConfig();
@@ -22,6 +22,6 @@ export const syncArticlesFromQiita = async ({
2222
const result = userConfig.includePrivate
2323
? items
2424
: items.filter((item) => !item.private);
25-
await fileSystemRepo.saveItems(result, isLocalUpdate);
25+
await fileSystemRepo.saveItems(result, forceUpdate);
2626
}
2727
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy