mirror of
				https://github.com/KevinMidboe/waka-box.git
				synced 2025-10-29 18:00:21 +00:00 
			
		
		
		
	Fix JS formatting (#5)
This commit is contained in:
		
				
					committed by
					
						 Matan Kushner
						Matan Kushner
					
				
			
			
				
	
			
			
			
						parent
						
							cfd410180c
						
					
				
				
					commit
					794f1b650a
				
			
							
								
								
									
										37
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								index.js
									
									
									
									
									
								
							| @@ -1,23 +1,28 @@ | |||||||
| require('dotenv').config(); | require('dotenv').config(); | ||||||
| const Twitter = require('twitter'); | const Twitter = require('twitter'); | ||||||
| const Octokit = require('@octokit/rest') | const Octokit = require('@octokit/rest'); | ||||||
| const wordwrap = require('wordwrap'); | const wordwrap = require('wordwrap'); | ||||||
| const { formatDistanceStrict } = require('date-fns'); | const { formatDistanceStrict } = require('date-fns'); | ||||||
|  |  | ||||||
| const { | const { | ||||||
|   TWITTER_USER: twitterHandle, |   TWITTER_USER: twitterHandle, | ||||||
|   GIST_ID: gistId, |   GIST_ID: gistId, | ||||||
|  |   TWITTER_CONSUMER_KEY: consumerKey, | ||||||
|  |   TWITTER_CONSUMER_SECRET: consumerSecret, | ||||||
|  |   TWITTER_ACCESS_TOKEN_KEY: accessTokenKey, | ||||||
|  |   TWITTER_ACCESS_TOKEN_SECRET: accessTokenSecret, | ||||||
|  |   GITHUB_TOKEN: githubToken, | ||||||
| } = process.env; | } = process.env; | ||||||
|  |  | ||||||
| const twitter = new Twitter({ | const twitter = new Twitter({ | ||||||
|   consumer_key: process.env.TWITTER_CONSUMER_KEY, |   consumer_key: consumerKey, | ||||||
|   consumer_secret: process.env.TWITTER_CONSUMER_SECRET, |   consumer_secret: consumerSecret, | ||||||
|   access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY, |   access_token_key: accessTokenKey, | ||||||
|   access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET |   access_token_secret: accessTokenSecret, | ||||||
| }); | }); | ||||||
|  |  | ||||||
| const octokit = new Octokit({ | const octokit = new Octokit({ | ||||||
|   auth: `token ${process.env.GITHUB_TOKEN}` |   auth: `token ${githubToken}`, | ||||||
| }); | }); | ||||||
|  |  | ||||||
| async function main() { | async function main() { | ||||||
| @@ -25,7 +30,7 @@ async function main() { | |||||||
|     screen_name: twitterHandle,  |     screen_name: twitterHandle,  | ||||||
|     count: 1, |     count: 1, | ||||||
|     trim_user: 1, |     trim_user: 1, | ||||||
|     exclude_replies: true |     exclude_replies: true, | ||||||
|    }); |    }); | ||||||
|  |  | ||||||
|   const tweet = timeline[0]; |   const tweet = timeline[0]; | ||||||
| @@ -39,7 +44,7 @@ async function updateGist(tweet) { | |||||||
|   try { |   try { | ||||||
|     gist = await octokit.gists.get({ gist_id: gistId }); |     gist = await octokit.gists.get({ gist_id: gistId }); | ||||||
|   } catch (error) { |   } catch (error) { | ||||||
|     console.error(`Unable to get gist\n${error}`) |     console.error(`Unable to get gist\n${error}`); | ||||||
|   } |   } | ||||||
|   // Get original filename to update that same file |   // Get original filename to update that same file | ||||||
|   const filename = Object.keys(gist.data.files)[0]; |   const filename = Object.keys(gist.data.files)[0]; | ||||||
| @@ -51,16 +56,16 @@ async function updateGist(tweet) { | |||||||
|       gist_id: gistId, |       gist_id: gistId, | ||||||
|       files: { |       files: { | ||||||
|         [filename]: { |         [filename]: { | ||||||
|           'filename': `@${twitterHandle} - ${timeAgo} ago | ❤ ${tweet.favorite_count} | 🔁 ${tweet.retweet_count}`, |           filename: `@${twitterHandle} - ${timeAgo} ago | ❤ ${tweet.favorite_count} | 🔁 ${tweet.retweet_count}`, | ||||||
|           content: wrap(tweet.text) |           content: wrap(tweet.text), | ||||||
|         } |         }, | ||||||
|       } |       }, | ||||||
|     }) |     }); | ||||||
|   } catch (error) { |   } catch (error) { | ||||||
|     console.error(`Unable to update gist\n${error}`) |     console.error(`Unable to update gist\n${error}`); | ||||||
|   } |  | ||||||
|   } |   } | ||||||
|  | }; | ||||||
|  |  | ||||||
| (async () => { | (async () => { | ||||||
|   await main(); |   await main(); | ||||||
| })() | })(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user