Skip to content

Commit

Permalink
Fix #76: Add Support for windows
Browse files Browse the repository at this point in the history
 - move config.js before base.js in the Makefile so config options are
   set first
 - disable colors if Windows detected
 - add more verbose windows_warning on startup with suggestion to use
   ConEmu
 - add force_color option for Windows users who know their term has
   color support
  • Loading branch information
stennie committed Oct 15, 2014
1 parent d2cf544 commit 87c9f93
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ config = config.js

all: mongo_hacker.js install

mongo_hacker.js: ${base} ${config} ${hacks}
mongo_hacker.js: ${config} ${base} ${hacks}
cat $^ > $@

install:
Expand Down
22 changes: 8 additions & 14 deletions base.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
/*
*
* Mongo-Hacker
* MongoDB Shell Enhancements for Hackers
*
* Tyler J. Brock - 2013
*
* http://tylerbrock.github.com/mongo-hacker
*
*/

if (_isWindows()) {
print("\nSorry! MongoDB Shell Enhancements for Hackers isn't compatible with Windows.\n");
if (_isWindows() && mongo_hacker_config['windows_warning']) {
print("\nMongoDB Shell Enhancements for Hackers does not support color highlighting in ");
print("the default Windows Command Prompt. If you are using an alternative console ");
print("such as ConEmu (https:/Maximus5/ConEmu) you may wish to try enabling");
print("highlighting in your mongo_hacker config by setting:");
print("\n\tforce_color: true\n");
print("You can hide this startup warning by setting:");
print("\n\twindows_warning: false\n");
}

if (typeof db !== 'undefined') {
Expand All @@ -20,4 +15,3 @@ if (typeof db !== 'undefined') {
print("Sorry! MongoDB Shell Enhancements for Hackers is only compatible with Mongo 2.2+\n");
}
}

13 changes: 13 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
*
* Mongo-Hacker
* MongoDB Shell Enhancements for Hackers
*
* Tyler J. Brock - 2013

This comment has been minimized.

Copy link
@tobsn

tobsn Jan 9, 2015

Contributor

2015? :)

*
* http://tylerbrock.github.com/mongo-hacker
*
*/

mongo_hacker_config = {
verbose_shell: true, // additional verbosity
index_paranoia: false, // querytime explain
Expand All @@ -8,6 +19,8 @@ mongo_hacker_config = {
banner_message: 'Mongo-Hacker ', // banner message
version: '0.0.4', // current mongo-hacker version
show_banner: true, // show mongo-hacker version banner on startup
windows_warning: true, // show warning banner for windows
force_color: false, // force color highlighting for Windows users

// Shell Color Settings
// Colors available: red, green, yellow, blue, magenta, cyan
Expand Down
2 changes: 1 addition & 1 deletion hacks/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function controlCode( parameters ) {
};

function applyColorCode( string, properties ) {
return controlCode(properties) + String(string) + controlCode();
return __colorize ? controlCode(properties) + String(string) + controlCode() : String(string);
};

function colorize( string, color ) {
Expand Down
1 change: 1 addition & 0 deletions hacks/common.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
__indent = Array(mongo_hacker_config.indent + 1).join(' ');
__colorize = (_isWindows() && !mongo_hacker_config['force_color']) ? false : true;

ObjectId.prototype.toString = function() {
return this.str;
Expand Down

0 comments on commit 87c9f93

Please sign in to comment.