This repository has been archived by the owner on Mar 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from cjsaylor/slack-support
Slack support
- Loading branch information
Showing
10 changed files
with
1,259 additions
and
854 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
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,23 +1,23 @@ | ||
/*global module:false*/ | ||
module.exports = function(grunt) { | ||
"use strict"; | ||
grunt.initConfig({ | ||
eslint : { | ||
library: 'lib/**' | ||
}, | ||
mochaTest: { | ||
test: { | ||
options: { | ||
reporter: "spec", | ||
require: "test/support/bootstrap" | ||
}, | ||
src: ["test/spec/**/*.js"] | ||
} | ||
} | ||
}); | ||
grunt.loadNpmTasks('grunt-eslint'); | ||
grunt.loadNpmTasks('grunt-mocha-test'); | ||
'use strict'; | ||
grunt.initConfig({ | ||
eslint : { | ||
library: 'lib/**' | ||
}, | ||
mochaTest: { | ||
test: { | ||
options: { | ||
reporter: 'spec', | ||
require: 'test/support/bootstrap' | ||
}, | ||
src: ['test/spec/**/*.js'] | ||
} | ||
} | ||
}); | ||
grunt.loadNpmTasks('grunt-eslint'); | ||
grunt.loadNpmTasks('grunt-mocha-test'); | ||
|
||
// Default task. | ||
grunt.registerTask('default', ['eslint', 'mochaTest']); | ||
// Default task. | ||
grunt.registerTask('default', ['eslint', 'mochaTest']); | ||
}; |
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
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
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,15 @@ | ||
const fs = require('fs'); | ||
const _ = require('lodash'); | ||
const { IncomingWebhook } = require('@slack/client'); | ||
|
||
module.exports = class Slack { | ||
constructor(webhookURL) { | ||
const template = fs.readFileSync(__dirname + '/../../templates/slack.md').toString(); | ||
this.compiledTemplate = _.template(template); | ||
this.hook = new IncomingWebhook(webhookURL); | ||
} | ||
|
||
async notify(repos) { | ||
await this.hook.send(this.compiledTemplate({ repos: repos })); | ||
} | ||
}; |
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,16 +1,22 @@ | ||
var Notifier = module.exports = function() { | ||
this.notifiers = []; | ||
}; | ||
module.exports = class Notifier { | ||
constructor() { | ||
this.notifiers = []; | ||
} | ||
|
||
Notifier.prototype.add = function(notifier) { | ||
if (!notifier.notify) { | ||
throw new Error('Provided notifier must implemnt a notify method.'); | ||
add(notifier) { | ||
if (!notifier.notify) { | ||
throw new Error('Provided notifier must implemnt a notify method.'); | ||
} | ||
this.notifiers.push(notifier); | ||
} | ||
this.notifiers.push(notifier); | ||
}; | ||
|
||
Notifier.prototype.notifyAll = function(repoData) { | ||
this.notifiers.forEach(function(notifier) { | ||
notifier.notify(repoData); | ||
}); | ||
length() { | ||
return this.notifiers.length; | ||
} | ||
|
||
notifyAll(repoData) { | ||
this.notifiers.forEach(function (notifier) { | ||
notifier.notify(repoData); | ||
}); | ||
} | ||
}; |
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
Oops, something went wrong.