-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update the list of global events #625
Changes from all commits
9ea7e70
cc65d20
b5f1e09
3fa60eb
06fc6e7
5db68a3
25f34d3
ba8336d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,31 +5,35 @@ const fs = require('fs') | |
const path = require('path') | ||
|
||
const p = path.join(__dirname, '..', 'locale', 'en', 'get-involved', 'events.md') | ||
const lines = fs.readFileSync(p).toString().split('\n') | ||
const begin = lines.indexOf('---') + 1 | ||
const end = lines.indexOf('---', begin) | ||
const store = yaml.safeLoad(lines.slice(begin, end).join('\n')) | ||
|
||
function getRegion (region) { | ||
let reg | ||
for (reg in store.regions) { | ||
if (store.regions[reg].region === region) return store.regions[reg] | ||
|
||
// | ||
// Slice the file contents to get the YAML source code. | ||
// | ||
const contents = fs.readFileSync(p, { encoding: 'utf8' }).trim().slice(4, -4) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please add a comment about slicing? (YAML head, I know, but it's not that obvious.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do. |
||
const store = yaml.safeLoad(contents) | ||
|
||
store.regions || (store.regions = []) | ||
|
||
function getRegion (name) { | ||
let region = store.regions.find((reg) => reg.region === name) | ||
|
||
if (!region) { | ||
region = { region: name } | ||
store.regions.push(region) | ||
} | ||
reg = { region: region } | ||
store.regions.push(reg) | ||
return reg | ||
|
||
return region | ||
} | ||
|
||
/** | ||
* This function checks if an event has been manually edited to prevent it | ||
* from being overwritten the next time event scripts are run. | ||
* | ||
* See https://github.com/nodejs/nodejs.org/pull/398. | ||
*/ | ||
function isSoT (meetups, city, name) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, what's this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add a reference to #398. |
||
for (let i = 0; i < meetups.length; i++) { | ||
if (meetups[i].city === city && meetups[i].name === name) { | ||
if (meetups[i].source_of_truth) { | ||
return true | ||
} | ||
return false | ||
} | ||
} | ||
return false | ||
const meetup = meetups.find((evt) => evt.city === city && evt.name === name) | ||
return meetup && meetup.source_of_truth | ||
} | ||
|
||
function removeEmpty (dict) { | ||
|
@@ -39,19 +43,23 @@ function removeEmpty (dict) { | |
} | ||
|
||
function replace (list, key, keyValue, value) { | ||
const index = list.findIndex((elem) => elem[key] === keyValue) | ||
|
||
removeEmpty(value) | ||
for (let i = 0; i < list.length; i++) { | ||
if (list[i][key] === keyValue) { | ||
list[i] = value | ||
return | ||
} | ||
|
||
if (index !== -1) { | ||
list[index] = value | ||
} else { | ||
list.push(value) | ||
} | ||
list.push(value) | ||
} | ||
|
||
function save () { | ||
const str = ['---', yaml.dump(store), '---'].join('\n') | ||
fs.writeFileSync(p, str) | ||
fs.writeFileSync(p, [ | ||
'---', | ||
yaml.safeDump(store, { lineWidth: Infinity }), | ||
'---' | ||
].join('\n')) | ||
} | ||
|
||
exports.removeEmpty = removeEmpty | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not
title.includes('mongodb')
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because there are some MongoDB+Node.js events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are also a lot of irrelevant events like Angular Ember etc but it's kinda hard to have ONLY relevant Node.js events. This a flaw in Meetup categories and topics.