Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
daba0d13
...
daba0d1351d3cd5e01b4bc6001681e0c2747665e
authored
2012-01-19 10:56:52 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
suppressed colorized output syntax for windows; was making output hard to read
1 parent
46535ed5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
4 deletions
bin/bootstrap.js
modules/colorizer.js
tests/suites/fs.js
bin/bootstrap.js
View file @
daba0d1
...
...
@@ -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
);
...
...
modules/colorizer.js
View file @
daba0d1
...
...
@@ -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
t
his
.
format
(
text
,
styles
[
styleName
],
pad
)
;
if
(
fs
.
isWindows
()
||
!
(
styleName
in
styles
)
)
{
return
t
ext
;
}
return
t
ext
;
return
t
his
.
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
=
[];
...
...
tests/suites/fs.js
View file @
daba0d1
...
...
@@ -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
...
...
Please
register
or
sign in
to post a comment