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
e4aafdf9
...
e4aafdf9a0d47428c5bdae9b0fa7a4407b84b3bd
authored
2012-01-18 19:22:24 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixes #41 - injecting casperjs lib crashes cmd.exe on Windows 7
1 parent
5d79ee63
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
bin/bootstrap.js
tests/suites/fs.js
bin/bootstrap.js
View file @
e4aafdf
...
...
@@ -54,7 +54,7 @@ phantom.loadCasper = function() {
}
if
(
!
fs
.
hasOwnProperty
(
'dirname'
))
{
fs
.
dirname
=
function
(
path
)
{
return
path
.
replace
(
/
\
/[^\/]
*
\/?
$/
,
''
);
return
path
.
replace
(
/
\
\
/g
,
'/'
).
replace
(
/
\/[^\/]
*
$/
,
''
);
};
}
if
(
!
fs
.
hasOwnProperty
(
'pathJoin'
))
{
...
...
@@ -151,7 +151,7 @@ phantom.loadCasper = function() {
}
// trick to locate source file location on error
scriptCode
+=
";var __fe__ = new CasperError('__sourceId__')"
;
scriptCode
+=
";__fe__.fileName = '"
+
file
+
"'"
;
scriptCode
+=
";__fe__.fileName = '"
+
file
.
replace
(
/
\\
+/g
,
'/'
)
+
"'"
;
scriptCode
+=
";throw __fe__;"
;
return
scriptCode
;
};
...
...
@@ -211,7 +211,7 @@ phantom.loadCasper = function() {
paths
.
push
(
path
);
}
else
{
dir
=
fs
.
absolute
(
requireDir
);
while
(
dir
!==
''
)
{
while
(
dir
!==
''
&&
dir
.
lastIndexOf
(
':'
)
!==
dir
.
length
-
1
)
{
// nodejs compatibility
paths
.
push
(
fs
.
pathJoin
(
dir
,
'node_modules'
,
path
));
dir
=
fs
.
dirname
(
dir
);
...
...
tests/suites/fs.js
0 → 100644
View file @
e4aafdf
var
fs
=
require
(
'fs'
),
t
=
casper
.
test
;
// Testing added methods
(
function
()
{
t
.
comment
(
'fs.dirname()'
);
var
tests
=
{
'/local/plop/foo.js'
:
'/local/plop'
,
'local/plop/foo.js'
:
'local/plop'
,
'./local/plop/foo.js'
:
'./local/plop'
,
'c:\\local\\plop\\foo.js'
:
'c:/local/plop'
,
'D:\\local\\plop\\foo.js'
:
'D:/local/plop'
,
'D:\\local\\plop\\'
:
'D:/local/plop'
,
'c:\\'
:
'c:'
,
'c:'
:
'c:'
};
for
(
var
testCase
in
tests
)
{
t
.
assertEquals
(
fs
.
dirname
(
testCase
),
tests
[
testCase
],
'fs.dirname() does its job for '
+
testCase
);
}
})();
t
.
done
();
\ No newline at end of file
Please
register
or
sign in
to post a comment