Fix JS formatting (#5)

This commit is contained in:
Zeeshan Ahmad
2019-03-16 21:31:54 +04:00
committed by Matan Kushner
parent cfd410180c
commit 794f1b650a

View File

@@ -1,23 +1,28 @@
require('dotenv').config();
const Twitter = require('twitter');
const Octokit = require('@octokit/rest')
const Octokit = require('@octokit/rest');
const wordwrap = require('wordwrap');
const { formatDistanceStrict } = require('date-fns');
const {
TWITTER_USER: twitterHandle,
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;
const twitter = new Twitter({
consumer_key: process.env.TWITTER_CONSUMER_KEY,
consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY,
access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET
consumer_key: consumerKey,
consumer_secret: consumerSecret,
access_token_key: accessTokenKey,
access_token_secret: accessTokenSecret,
});
const octokit = new Octokit({
auth: `token ${process.env.GITHUB_TOKEN}`
auth: `token ${githubToken}`,
});
async function main() {
@@ -25,7 +30,7 @@ async function main() {
screen_name: twitterHandle,
count: 1,
trim_user: 1,
exclude_replies: true
exclude_replies: true,
});
const tweet = timeline[0];
@@ -39,7 +44,7 @@ async function updateGist(tweet) {
try {
gist = await octokit.gists.get({ gist_id: gistId });
} 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
const filename = Object.keys(gist.data.files)[0];
@@ -51,16 +56,16 @@ async function updateGist(tweet) {
gist_id: gistId,
files: {
[filename]: {
'filename': `@${twitterHandle} - ${timeAgo} ago | ❤ ${tweet.favorite_count} | 🔁 ${tweet.retweet_count}`,
content: wrap(tweet.text)
}
}
})
filename: `@${twitterHandle} - ${timeAgo} ago | ❤ ${tweet.favorite_count} | 🔁 ${tweet.retweet_count}`,
content: wrap(tweet.text),
},
},
});
} catch (error) {
console.error(`Unable to update gist\n${error}`)
console.error(`Unable to update gist\n${error}`);
}
}
};
(async () => {
await main();
})()
})();