bagofholding
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -1,2 +0,5 @@ | ||
### 0.0.3 (SNAPSHOT) | ||
### 0.0.4 (SNAPSHOT) | ||
* Mock console error and log now simulates %s, %d, %j | ||
### 0.0.3 | ||
* Modify cli readConfigFileSync, config file in current directory should take precedence over the one in home directory | ||
@@ -3,0 +6,0 @@ |
@@ -106,2 +106,3 @@ var obj = require('./obj'); | ||
* Mock console module. | ||
* error and log functions accept any number of arguments | ||
**/ | ||
@@ -113,9 +114,24 @@ function console(checks) { | ||
function error(message) { | ||
checks.console_error_messages.push(message); | ||
// a simple format to simulate parts of util.format | ||
// util.format is not used because it's not available in node v0.4.x | ||
function _format(text, args) { | ||
var i = 1, | ||
formatted = String(text).replace(/%[sdj]/g, function (match) { | ||
switch(match) { | ||
case '%s': return String(args[i++]); | ||
case '%d': return Number(args[i++]); | ||
case '%j': return JSON.stringify(args[i++]); | ||
default: return match; | ||
} | ||
}); | ||
return formatted; | ||
} | ||
function log(message) { | ||
checks.console_log_messages.push(message); | ||
function error(message, arg1, arg2, arg3) { | ||
checks.console_error_messages.push(_format(message, error['arguments'])); | ||
} | ||
function log(message, arg1, arg2, arg3) { | ||
checks.console_log_messages.push(_format(message, log['arguments'])); | ||
} | ||
@@ -122,0 +138,0 @@ return { |
@@ -5,3 +5,3 @@ { | ||
"keywords": [], | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"homepage": "http://github.com/cliffano/bagofholding", | ||
@@ -8,0 +8,0 @@ "author": "Cliffano Subagio <blah@cliffano.com> (http://blog.cliffano.com)", |
@@ -101,4 +101,6 @@ var bag = require('../lib/bagofholding'), | ||
console.error('some error'); | ||
checks.console_error_messages.length.should.equal(1); | ||
console.error('foo %s', 'bar'); | ||
checks.console_error_messages.length.should.equal(2); | ||
checks.console_error_messages[0].should.equal('some error'); | ||
checks.console_error_messages[1].should.equal('foo bar'); | ||
}); | ||
@@ -109,4 +111,6 @@ | ||
console.log('some log'); | ||
checks.console_log_messages.length.should.equal(1); | ||
console.log('foo %s', 'bar'); | ||
checks.console_log_messages.length.should.equal(2); | ||
checks.console_log_messages[0].should.equal('some log'); | ||
checks.console_log_messages[1].should.equal('foo bar'); | ||
}); | ||
@@ -113,0 +117,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44652
1118