Commit daba0d13 daba0d1351d3cd5e01b4bc6001681e0c2747665e by Nicolas Perriault

suppressed colorized output syntax for windows; was making output hard to read

1 parent 46535ed5
......@@ -57,6 +57,12 @@ phantom.loadCasper = function() {
return path.replace(/\\/g, '/').replace(/\/[^\/]*$/, '');
};
}
if (!fs.hasOwnProperty('isWindows')) {
fs.isWindows = function() {
var testPath = arguments[0] || this.workingDirectory;
return (/^[a-z]{1,2}:/i).test(testPath) || testPath.indexOf("\\\\") === 0;
};
}
if (!fs.hasOwnProperty('pathJoin')) {
fs.pathJoin = function() {
return Array.prototype.join.call(arguments, this.separator);
......
......@@ -28,6 +28,9 @@
*
*/
var fs = require('fs');
var utils = require('utils');
exports.create = function create() {
return new Colorizer();
};
......@@ -62,10 +65,10 @@ var Colorizer = function() {
* @return String
*/
this.colorize = function colorize(text, styleName, pad) {
if (styleName in styles) {
return this.format(text, styles[styleName], pad);
if (fs.isWindows() || !(styleName in styles)) {
return text;
}
return text;
return this.format(text, styles[styleName], pad);
};
/**
......@@ -76,7 +79,7 @@ var Colorizer = function() {
* @return String
*/
this.format = function format(text, style, pad) {
if (typeof style !== "object") {
if (fs.isWindows() || !utils.isObject(style)) {
return text;
}
var codes = [];
......
......@@ -18,4 +18,19 @@ var fs = require('fs'), t = casper.test;
}
})();
(function() {
t.comment('fs.dirname()');
var tests = {
'/': false,
'/local/plop/foo.js': false,
'D:\\local\\plop\\': true,
'c:\\': true,
'c:': true,
'\\\\Server\\Plop': true
};
for (var testCase in tests) {
t.assertEquals(fs.isWindows(testCase), tests[testCase], 'fs.isWindows() does its job for ' + testCase);
}
})();
t.done();
\ No newline at end of file
......