Permalink
Browse files

Colorize. Fixes #38

  • Loading branch information...
1 parent 88bd999 commit 5a1d162d2938e2e1b5b70182f5350b87697fb6fa @sindresorhus sindresorhus committed Apr 25, 2012
Showing with 15 additions and 13 deletions.
  1. +2 −1 package.json
  2. +13 −12 pulley.js
View
3 package.json
@@ -17,7 +17,8 @@
},
"dependencies": {
"prompt": "~0.1.12",
- "request": "~2.9.202"
+ "request": "~2.9.202",
+ "colors": "~0.6.0"
},
"preferGlobal": "true",
"licenses": [{
View
25 pulley.js
@@ -12,6 +12,7 @@
fs = require("fs"),
prompt = require("prompt"),
request = require("request"),
+ colors = require("colors"),
// Process references
exec = child.exec,
@@ -32,7 +33,7 @@
// We don't want the default prompt message
prompt.message = "";
- process.stdout.write("Initializing... ");
+ process.stdout.write( "Initializing... ".blue );
exec( "git config --global --get pulley.token", function( error, stdout, stderr ) {
token = trim( stdout );
@@ -123,16 +124,16 @@
}
function getPullData() {
- process.stdout.write("done.\n");
- process.stdout.write("Getting pull request details... ");
+ console.log( "done.".green );
+ process.stdout.write( "Getting pull request details... ".blue );
callApi({
path: "/repos/" + user_repo + "/pulls/" + id
}, function( data ) {
try {
var pull = JSON.parse( data );
- process.stdout.write("done.\n");
+ console.log( "done.".green );
if ( done ) {
commit( pull );
@@ -157,7 +158,7 @@
"git checkout -b " + branch
];
- process.stdout.write("Pulling and merging results... ");
+ process.stdout.write( "Pulling and merging results... ".blue );
if ( pull.state === "closed" ) {
exit("Can not merge closed Pull Requests.");
@@ -194,15 +195,15 @@
exit("Merge conflict. Please resolve then run: " +
process.argv.join(" ") + " done");
} else {
- process.stdout.write("done.\n");
+ console.log( "done.".green );
commit( pull );
}
});
}
}
function commit( pull ) {
- process.stdout.write("Getting author and committing changes... ");
+ process.stdout.write( "Getting author and committing changes... ".blue );
callApi({
path: "/repos/" + user_repo + "/pulls/" + id + "/commits"
@@ -256,7 +257,7 @@
reset("No commit, aborting push.");
} else {
exec( "git push " + config.remote + " " + base_branch, function( error, stdout, stderr ) {
- process.stdout.write("done.\n");
+ console.log( "done.".green );
exit();
});
}
@@ -315,18 +316,18 @@
}
function reset( msg ) {
- console.error( "\n" + msg );
- process.stderr.write("Resetting files... ");
+ console.error( ( "\n" + msg ).red );
+ process.stderr.write( "Resetting files... ".red );
exec( "git reset --hard ORIG_HEAD", function() {
- process.stderr.write("done.\n");
+ console.log( "done.".green );
exit();
});
}
function exit( msg ) {
if ( msg ) {
- console.error( "\nError: " + msg );
+ console.error( ( "\nError: " + msg ).red );
}
process.exit( 1 );

0 comments on commit 5a1d162

Please sign in to comment.