Skip to content

Commit

Permalink
Adapt welcome-tweet script for this year
Browse files Browse the repository at this point in the history
  • Loading branch information
rradczewski committed Jul 3, 2019
1 parent aedd406 commit 86d2cac
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
language: node_js
cache: yarn

after_success: ./scripts/print_welcome_tweet.sh
after_success: node ./scripts/print_welcome_tweet.js
32 changes: 32 additions & 0 deletions scripts/print_welcome_tweet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const fs = require("fs");
const path = require("path");
const glob = require("glob");
const DIR = "_data/events_gdcr2019";

const toWelcomeTweetModerators = moderators => {
const names = moderators.map(mod => {
if (typeof mod === "string") return mod;
if (mod.url.includes("twitter.com"))
return "@" + mod.url.split("/").slice(-1)[0];
return mod.name;
});
if (names.length === 1) return names[0];
return names.slice(0, -1).join(", ") + " & " + names.slice(-1)[0];
};

const toWelcomeTweet = event => {
const moderators = toWelcomeTweetModerators(event.moderators);
return `🌐 Welcome ${event.location.city}, ${
event.location.country
} with ${moderators} to the Global Day Of Coderetreat 2019! #gdcr19 #coderetreat ${
event.url
}`;
};

const events = glob
.sync(path.resolve(__dirname, "../_data/events_gdcr2019/") + "/*.json")
.sort((fa, fb) => fs.statSync(fa).mtimeMs - fs.statSync(fb).mtimeMs)
.map(file => JSON.parse(fs.readFileSync(file)))
.map(toWelcomeTweet);

console.log(events.join("\n"));
23 changes: 0 additions & 23 deletions scripts/print_welcome_tweet.sh

This file was deleted.

0 comments on commit 86d2cac

Please sign in to comment.