Skip to content

Commit

Permalink
(Agrega) Nuevos releases a observar (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
leocabeza authored May 27, 2017
1 parent 6256788 commit 6f9a2cb
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
28 changes: 27 additions & 1 deletion config/config.sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,33 @@ const config = {
},
id: '41469246',
hashtagMessage: '#ngVenezuelaTweet'
}
},
githubReleases: [
{
name: 'angular',
repo: 'angular/angular',
hasChangelog: true,
feed: 'https://github.com/angular/angular/releases.atom'
},
{
name: 'ionic',
repo: 'driftyco/ionic',
hasChangelog: true,
feed: 'https://github.com/driftyco/ionic/releases.atom'
},
{
name: 'nativescript',
repo: 'NativeScript/NativeScript',
hasChangelog: true,
feed: 'https://github.com/NativeScript/NativeScript/releases.atom'
},
{
name: 'wengy-ven',
repo: 'ngVenezuela/wengy-ven',
hasChangelog: false,
feed: 'https://github.com/ngVenezuela/wengy-ven/releases.atom'
}
]
}
};

Expand Down
9 changes: 1 addition & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ new TwitterEvent()
.on('newTweet', tweet => twitterUtility.sendNewTweet(bot, tweet));

superfeedr
.on('newFeed', feed =>
githubUtility.checkForRelease('angular/angular', feed)
&& githubUtility.sendRelease(bot, feed, 'angular/angular', true)
)
.on('newFeed', feed =>
githubUtility.checkForRelease('ngVenezuela/wengy-ven', feed)
&& githubUtility.sendRelease(bot, feed, 'ngVenezuela/wengy-ven', false)
)
.on('newFeed', feed => githubUtility.checkAndSendRelease(bot, feed))
.on('newFeed', feed =>
blogUtility.checkForBlogEntry(feed) && blogUtility.sendNewBlogEntries(bot, feed));
18 changes: 14 additions & 4 deletions src/utils/github-release.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const config = require('./../../config/config');
const groupId = require('./../../config/config').groupId;
const releasesToCheck = require('./../../config/config').integrations.githubReleases;
const githubReleaseMessage = require('./../../config/messages').githubRelease;
const sendMessage = require('./../utils/send-message');

const checkForRelease = (repository, feed) =>
const isItAGithubRelease = (repository, feed) =>
feed && feed.status.feed && feed.status.feed.search(repository) !== -1;

const sendRelease = (bot, release, repository, changelogExist) => {
Expand All @@ -17,7 +18,7 @@ const sendRelease = (bot, release, repository, changelogExist) => {

sendMessage(
bot,
config.groupId,
groupId,
githubReleaseMessage
.replace('#{name}', name)
.replace('#{version}', tag)
Expand All @@ -31,7 +32,16 @@ const sendRelease = (bot, release, repository, changelogExist) => {
});
};

const checkAndSendRelease = (bot, feed) => {
releasesToCheck.forEach((release) => {
if (isItAGithubRelease(release.repo, feed)) {
sendRelease(bot, feed, release.repo, release.hasChangelog);
}
});
};

module.exports = {
checkForRelease,
checkAndSendRelease,
isItAGithubRelease,
sendRelease
};

0 comments on commit 6f9a2cb

Please sign in to comment.