Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

can now add a hook

  • Loading branch information...
commit 2595782ba07d455eb3727f4f54a173ac5695f84a 1 parent 10de31e
@substack authored
Showing with 22 additions and 4 deletions.
  1. +19 −2 bin/cmd.js
  2. +3 −2 package.json
View
21 bin/cmd.js
@@ -15,6 +15,15 @@ function remote (cb) {
}
withConfig(function (config) {
+ var doc = {
+ name : 'travis',
+ config : {
+ token : config.token,
+ domain : '',
+ user : config.user,
+ },
+ };
+
remote(function (err, repo) {
if (err) return console.error(err);
@@ -22,9 +31,8 @@ withConfig(function (config) {
+ [ config.user, config.pass ].map(encodeURIComponent).join(':')
+ '@api.github.com/repos/' + repo + '/hooks'
;
- var opts = { uri : uri, json : true };
- request.get(opts, function (err, res, body) {
+ request.get({ uri : uri, json : true }, function (err, res, body) {
if (err) return console.error(err);
if (res.statusCode !== 200) return console.error(body);
if (!Array.isArray(body)) {
@@ -40,6 +48,15 @@ withConfig(function (config) {
return console.log('this repo already has a travis hook');
}
+ var opts = {
+ uri : uri,
+ body : JSON.stringify(doc),
+ };
+ request.post(opts, function (err, res, body) {
+ if (err) console.error(err);
+ else if (res.statusCode !== 200) console.log(body)
+ else console.log('travis hook added for ' + repo)
+ });
});
});
});
View
5 package.json
@@ -1,6 +1,6 @@
{
"name" : "travisify",
- "description" : "easily update github admin hooks for travis-ci",
+ "description" : "add travis-ci hooks to github",
"version" : "0.0.0",
"repository" : {
"type" : "git",
@@ -10,7 +10,8 @@
"travisify" : "bin/cmd.js"
},
"dependencies" : {
- "mkdirp" : "~0.3.1"
+ "mkdirp" : "~0.3.1",
+ "request" : "~2.9.200"
},
"keywords" : [
"travis",

0 comments on commit 2595782

Please sign in to comment.
Something went wrong with that request. Please try again.