Skip to content

Commit

Permalink
removed nunt as dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
camme committed Feb 27, 2015
1 parent 2d28ed8 commit 7f9c7e0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 18 deletions.
10 changes: 10 additions & 0 deletions examples/deploys-just-echo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"deploys": [{
"name": "Webhook Deployer",
"type": "github",
"repo": "https://github.com/camme/webhook-deployer",
"basepath": "./",
"command": "echo HELLO WORLD",
"branch": "master"
}]
}
12 changes: 1 addition & 11 deletions lib/incoming.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ var webdep = require('./webdep');
var fs = require("fs");
var path = require("path");
var exec = require('child_process').exec;
var nunt = require("nunt");

exports.control = function(options) {

Expand Down Expand Up @@ -90,16 +89,6 @@ exports.control = function(options) {
};


nunt.on("run-deploy", function(e) {
if (e._client.handshake.session.authenticated === true) {
var deploy = webdep.getDeployFromId(e.id);
if (deploy) {
runDeploy(deploy);
}
}
});


function runDeploy(deploy) {

webdep.log("> Run " + deploy.name + " with branch " + deploy.branch);
Expand Down Expand Up @@ -142,4 +131,5 @@ function runDeploy(deploy) {

}

exports.runDeploy = runDeploy;

20 changes: 15 additions & 5 deletions lib/webdep.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var server = http.createServer();
var keys = Keygrip(['superhemligakoden']);
var options = {}; // extend the options
var io;
var incoming = require('./incoming');

if (fs.existsSync(path.join(__dirname, '../package.json'))) {
packageInformation = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'), 'utf8'));
Expand Down Expand Up @@ -57,7 +58,7 @@ exports.init = function(newOptions, callback) {

routes.push({
route: /^\/incoming\/(.*?)($|\/$)/gi,
action: require('./incoming').control(options)
action: incoming.control(options)
});

if (options.webui) {
Expand Down Expand Up @@ -187,14 +188,23 @@ exports.init = function(newOptions, callback) {
socket.request.session.authenticated = true;
sendLoginInfo(socket);

} else {
socket.request.session.authenticated = false;
socket.emit("login-error");
}
else {
});

socket.on("run-deploy", function(e) {
if (socket.request.session.authenticated === true) {
var deploy = getDeployFromId(e.id);
if (deploy) {
incoming.runDeploy(deploy);
}
} else {
socket.request.session.authenticated = false;
socket.emit("login-error");

}
});
});

// Check if the user already has logged in
if (socket.request && socket.request.session && socket.request.session.authenticated === true) {
Expand Down Expand Up @@ -313,7 +323,7 @@ function cookieSessions(name) {
}
}

exports.getDeployFromId = function(id) {
function getDeployFromId(id) {
var list = getDeployList();
for(var i = 0, ii = list.length; i < ii; i++){
var item = list[i];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webhook-deployer",
"version": "0.7.0",
"version": "0.7.1",
"description": "Deployer server app triggered by (github) webhooks",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
var buttons = document.querySelector(".deploys-box button");
buttons.addEventListener("click", function() {
var id = this.parentNode.parentNode.getAttribute("data-id");
nunt.send("run-deploy", {id: id});
socket.emit("run-deploy", {id: id});
}, false);
});

Expand Down

0 comments on commit 7f9c7e0

Please sign in to comment.