forked from coderetreat/coderetreat.org
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt welcome-tweet script for this year
- Loading branch information
1 parent
aedd406
commit 86d2cac
Showing
3 changed files
with
33 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); |
This file was deleted.
Oops, something went wrong.