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
9b80a0e4
...
9b80a0e4c5b13f61ecb59d5e24fa6ffc93de20a9
authored
2013-12-19 14:21:27 -0700
by
hexid
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Allow usage of require.paths, while maintaining support for versions of PhantomJ…
…S that don't support it
1 parent
5c80139c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
15 deletions
bin/bootstrap.js
bin/bootstrap.js
View file @
9b80a0e
...
...
@@ -352,22 +352,23 @@ CasperError.prototype = Object.getPrototypeOf(new Error());
};
})(
phantom
.
casperPath
);
if
(
"slimer"
in
global
)
{
// for SlimerJS, use the standard API to declare directories
// where to search modules
if
(
"paths"
in
global
.
require
)
{
// declare a dummy patchRequire function
global
.
patchRequire
=
function
(
req
)
{
return
req
;};
require
.
paths
.
push
(
fs
.
pathJoin
(
phantom
.
casperPath
,
'modules'
));
require
.
paths
.
push
(
fs
.
workingDirectory
);
// declare a dummy patchRequire function
require
.
globals
.
patchRequire
=
global
.
patchRequire
=
function
(
req
)
{
return
req
;};
require
.
globals
.
CasperError
=
CasperError
;
phantom
.
casperEngine
=
"slimerjs"
;
}
else
{
// patch require
}
else
{
global
.
__require
=
require
;
global
.
patchRequire
=
patchRequire
;
// must be called in every casperjs module as of 1.1
global
.
require
=
patchRequire
(
global
.
require
);
}
if
(
"slimer"
in
global
)
{
require
.
globals
.
patchRequire
=
global
.
patchRequire
;
require
.
globals
.
CasperError
=
CasperError
;
phantom
.
casperEngine
=
"slimerjs"
;
}
else
{
phantom
.
casperEngine
=
"phantomjs"
;
}
...
...
@@ -378,11 +379,13 @@ CasperError.prototype = Object.getPrototypeOf(new Error());
initCasperCli
(
phantom
.
casperArgs
);
}
if
(
"slimer"
in
global
&&
phantom
.
casperScriptBaseDir
)
{
// initCasperCli has set casperScriptBaseDir
// use it instead of fs.workingDirectory
require
.
paths
.
pop
();
if
(
"paths"
in
global
.
require
)
{
if
((
phantom
.
casperScriptBaseDir
||
""
).
indexOf
(
fs
.
workingDirectory
)
===
0
)
{
require
.
paths
.
push
(
phantom
.
casperScriptBaseDir
);
}
else
{
require
.
paths
.
push
(
fs
.
pathJoin
(
fs
.
workingDirectory
,
phantom
.
casperScriptBaseDir
));
}
require
.
paths
.
push
(
fs
.
pathJoin
(
require
.
paths
[
require
.
paths
.
length
-
1
],
'node_modules'
));
}
// casper loading status flag
...
...
Please
register
or
sign in
to post a comment