File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import {
1111 Repository ,
1212 UpdateStatus ,
1313} from './dev-to-git.interface' ;
14- import { formatArticlePublishedStatuses , logBuilder , Logger } from './helpers' ;
14+ import { Logger , formatArticlePublishedStatuses , logBuilder } from './helpers' ;
1515
1616export const DEFAULT_CONFIG_PATH : string = './dev-to-git.json' ;
1717
@@ -105,15 +105,18 @@ export class DevToGit {
105105 } ) ) ;
106106 }
107107
108- public publishArticles ( ) : Promise < ArticlePublishedStatus [ ] > {
108+ public async publishArticles ( ) : Promise < ArticlePublishedStatus [ ] > {
109109 const articles = this . readConfigFile ( ) ;
110110
111- return Promise . all (
112- articles . map ( articleConf => {
113- const article = new Article ( articleConf , this . configuration . devToToken ) ;
114- return article . publishArticle ( ) ;
115- } ) ,
116- ) ;
111+ const articlePublishedStatuses = [ ]
112+
113+ // instead of using Promise.all we use a for with await
114+ // to run the updates one by one to avoid hammering dev.to API
115+ // and have more risks of being rate limited
116+ for ( const articleConf of articles ) {
117+ const article = new Article ( articleConf , this . configuration . devToToken ) ;
118+ articlePublishedStatuses . push ( await article . publishArticle ( ) ) ;
119+ }
117120 }
118121}
119122
You can’t perform that action at this time.
0 commit comments