File tree Expand file tree Collapse file tree 4 files changed +22
-5
lines changed Expand file tree Collapse file tree 4 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -207,6 +207,14 @@ Qiita 上で更新を行い、手元で変更を行っていない記事ファ
207
207
npx qiita pull
208
208
```
209
209
210
+ ` --force ` オプションを用いることで、記事ファイルをを全て強制的に Qiita と同期します。
211
+
212
+ ``` console
213
+ npx qiita pull --force
214
+ # -f は--force のエイリアスとして使用できます。
215
+ npx qiita pull -f
216
+ ```
217
+
210
218
### version
211
219
212
220
Qiita CLI のバージョンを確認できます。
Original file line number Diff line number Diff line change @@ -7,12 +7,19 @@ import { QiitaApi } from "../qiita-api";
7
7
import { startLocalChangeWatcher , startServer } from "../server/app" ;
8
8
9
9
export const pull = async ( argv : string [ ] ) => {
10
- const args = arg ( { } , { argv } ) ;
10
+ const args = arg (
11
+ {
12
+ "--force" : Boolean ,
13
+ "-f" : "--force" ,
14
+ } ,
15
+ { argv }
16
+ ) ;
11
17
12
18
const qiitaApi = await getQiitaApiInstance ( ) ;
13
19
const fileSystemRepo = await getFileSystemRepo ( ) ;
20
+ const isLocalUpdate = args [ "--force" ] ;
14
21
15
- await syncArticlesFromQiita ( { fileSystemRepo, qiitaApi } ) ;
22
+ await syncArticlesFromQiita ( { fileSystemRepo, qiitaApi, isLocalUpdate } ) ;
16
23
console . log ( "Sync local articles from Qiita" ) ;
17
24
console . log ( "Successful!" ) ;
18
25
} ;
Original file line number Diff line number Diff line change @@ -276,9 +276,9 @@ export class FileSystemRepo {
276
276
}
277
277
}
278
278
279
- async saveItems ( items : Item [ ] ) {
279
+ async saveItems ( items : Item [ ] , isLocalUpdate : boolean = false ) {
280
280
const promises = items . map ( async ( item ) => {
281
- await this . syncItem ( item ) ;
281
+ await this . syncItem ( item , false , isLocalUpdate ) ;
282
282
} ) ;
283
283
284
284
await Promise . all ( promises ) ;
Original file line number Diff line number Diff line change @@ -5,9 +5,11 @@ import { config } from "./config";
5
5
export const syncArticlesFromQiita = async ( {
6
6
fileSystemRepo,
7
7
qiitaApi,
8
+ isLocalUpdate = false ,
8
9
} : {
9
10
fileSystemRepo : FileSystemRepo ;
10
11
qiitaApi : QiitaApi ;
12
+ isLocalUpdate ?: boolean ;
11
13
} ) => {
12
14
const per = 100 ;
13
15
const userConfig = await config . getUserConfig ( ) ;
@@ -20,6 +22,6 @@ export const syncArticlesFromQiita = async ({
20
22
const result = userConfig . includePrivate
21
23
? items
22
24
: items . filter ( ( item ) => ! item . private ) ;
23
- await fileSystemRepo . saveItems ( result ) ;
25
+ await fileSystemRepo . saveItems ( result , isLocalUpdate ) ;
24
26
}
25
27
} ;
You can’t perform that action at this time.
0 commit comments