Skip to content

Commit

Permalink
Merge pull request #18 from himynameisdave/add-banners
Browse files Browse the repository at this point in the history
Add banners
  • Loading branch information
himynameisdave committed Feb 9, 2016
2 parents 6459fae + e3236d3 commit a2963ea
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
18 changes: 18 additions & 0 deletions components/banners.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Responsible for the banners, and for printing them
*/
"use strict";

const bar = "=======================================\n";
const block = "]|[";
const emptyRow = block+" "+block+"\n";
const printBanner = ( banner ) => {
return () => console.log( bar + emptyRow + block + banner + block + "\n" + emptyRow + bar );
};

module.exports = {
addCustom: printBanner(" Adding Custom Labels "),
addFromPackage: printBanner(" Adding Labels From Package "),
removeLabels: printBanner(" Removing Labels "),
resetToken: printBanner(" Resetting Token ")
};
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const fs = require("fs"),
iq = require("inquirer"),
octonode = require("octonode"),
gitLabel = require("git-label"),
banner = require("./components/banners"),
readRepo = require("./components/read-repo"),
cleanup = require("./components/remove-tmp-pkg"),
mainPrompts = require("./components/main-prompts"),
Expand Down Expand Up @@ -135,6 +136,7 @@ const handleAddPrompts = (repo, token, newLabels) => {

const handleMainPrompts = (repo, ans) => {
if ( ans.main.toLowerCase() === "reset token" ){
banner.resetToken();
// process will end after new token is set
return setToken((token) => {
iq.prompt( mainPrompts, handleMainPrompts.bind(null, repo));
Expand All @@ -144,10 +146,11 @@ const handleMainPrompts = (repo, ans) => {
fetchToken()
.then((token)=>{
if ( ans.main.toLowerCase() === "add custom labels" ){
banner.addCustom();
return doCustomLabelPrompts( [], handleAddPrompts.bind(null, repo, token));
}
if ( ans.main.toLowerCase() === "add labels from package" ){
// return doPackageLabelPrompts( handleAddPrompts.bind(null, repo, token) );
banner.addFromPackage();
let packagePath;
iq.prompt([{
name: "path",
Expand Down Expand Up @@ -176,6 +179,7 @@ const handleMainPrompts = (repo, ans) => {
});
}
if ( ans.main.toLowerCase() === "remove labels" ){
banner.removeLabels();
doRemovePrompts(token, repo);
}
})
Expand Down

0 comments on commit a2963ea

Please sign in to comment.