-
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.
Resolves #14 - Separated out cli program from github client
- Loading branch information
1 parent
c39a6cc
commit d3d6656
Showing
5 changed files
with
136 additions
and
121 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict'; | ||
|
||
var github = require('octonode'); | ||
|
||
/******************************************************************** | ||
* FUNCTION CONSTRUCTOR | ||
*********************************************************************/ | ||
function GithubClient() { | ||
// Only specified if environment variable exists. | ||
this.ACCESS_TOKEN = process.env.GITHUB_LABEL_TOKEN; | ||
this.repository = ''; | ||
this.client = null; | ||
this.ghrepo = null; | ||
} | ||
|
||
|
||
/******************************************************************** | ||
* PUBLIC METHODS | ||
*********************************************************************/ | ||
GithubClient.prototype.setRepository = function(repository) { | ||
this.repository = repository; | ||
this.ghrepo = this.client.repo(this.repository); | ||
}; | ||
|
||
GithubClient.prototype.getRepository = function() { | ||
return this.repository; | ||
}; | ||
|
||
GithubClient.prototype.setupTokenClient = function() { | ||
this.client = github.client(this.ACCESS_TOKEN); | ||
this.setupGithubRepo(); | ||
}; | ||
|
||
GithubClient.prototype.setupAuthClient = function(username, password) { | ||
this.client = github.client({ | ||
username: username, | ||
password: password | ||
}); | ||
this.setupGithubRepo(); | ||
}; | ||
|
||
GithubClient.prototype.getLabels = function(callback) { | ||
this.ghrepo.labels(function(blank, data, header) { | ||
callback(data, header); | ||
}); | ||
}; | ||
|
||
GithubClient.prototype.postLabels = function(labels) { | ||
console.log('TODO: Send post request'); | ||
}; | ||
|
||
|
||
/******************************************************************** | ||
* MODULE EXPORT | ||
*********************************************************************/ | ||
module.exports = GithubClient; |
This file was deleted.
Oops, something went wrong.
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,6 +1,6 @@ | ||
'use strict'; | ||
|
||
exports.exit = function(message) { | ||
console.log('Exit: ' + message); | ||
console.log('\nExit: ' + message); | ||
process.exit(1); | ||
}; |
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,12 @@ | ||
'use strict'; | ||
|
||
var fs = require('fs'); | ||
var logging = require('./logging'); | ||
|
||
exports.readJSON = function(filepath, callback) { | ||
fs.readFile(filepath, 'utf8', function(error, data) { | ||
if (error) { | ||
logging.exit('could not read file: ' + filepath); | ||
} callback(JSON.parse(data)); | ||
}); | ||
}; |