Created
December 12, 2013 19:27
-
-
Save evantill/7933911 to your computer and use it in GitHub Desktop.
update github from node.js
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
var env = require('node-env-file'); | |
var Github = require('github-api'); | |
var Q = require('q'); | |
env(__dirname + '/.env'); | |
var github = new Github({ | |
username: "evantill", | |
password: process.env.GITHUB_PASSWORD, | |
auth: "basic" | |
}); | |
var repo = github.getRepo("evantill", "menu"); | |
var deferred = Q.defer(); | |
repo.write('master', 'menus/menu3.json', '{message:"hello there '+process.argv[2]+'"}', 'create new menu', function(err) { | |
if(err) { | |
console.log(JSON.stringify(err)); | |
deferred.reject(err); | |
} else { | |
console.log("done"); | |
deferred.resolve('menus/menu3.json'); | |
} | |
}); | |
Q.when(deferred.promise, function (value) { | |
repo.read('master', 'menus/menu3.json', function(err, data) { | |
if(err){ | |
console.log(JSON.stringify(err)); | |
} else { | |
console.log(data); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment