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
ff12c243
...
ff12c243ee66e674a8fccf534916142a004b0921
authored
2014-04-06 20:56:19 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #774 from hexid/phantomjs2-require-bc
Allow usage of require.paths
2 parents
c55c2670
b2c7ada7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
15 deletions
bin/bootstrap.js
bin/bootstrap.js
View file @
ff12c24
...
...
@@ -76,6 +76,7 @@ CasperError.prototype = Object.getPrototypeOf(new Error());
// casperjs env initialization
(
function
(
global
,
phantom
){
/*jshint maxstatements:99*/
"use strict"
;
// phantom args
// NOTE: we can't use require('system').args here for some very obscure reason
...
...
@@ -352,22 +353,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 +380,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