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
602e87f5
...
602e87f5d0abca6b702d3f89bcdb4d9b5023a85e
authored
2012-01-11 21:14:56 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixed patched require() could not open local modules
1 parent
15733d77
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
43 deletions
bin/bootstrap.js
bin/bootstrap.js
View file @
602e87f
...
...
@@ -201,53 +201,55 @@ phantom.loadCasper = function() {
};
if
(
phantomBuiltins
.
indexOf
(
path
)
!==
-
1
)
{
return
phantomRequire
(
path
);
}
if
(
path
[
0
]
===
'.'
)
{
paths
.
push
.
apply
(
paths
,
[
fs
.
absolute
(
path
),
fs
.
absolute
(
fs
.
pathJoin
(
requireDir
,
path
))
]);
}
else
if
(
path
[
0
]
===
'/'
)
{
paths
.
push
(
path
);
}
else
{
if
(
path
[
0
]
===
'.'
)
{
paths
.
push
(
fs
.
absolute
(
fs
.
pathJoin
(
requireDir
,
path
)));
}
else
if
(
path
[
0
]
===
'/'
)
{
paths
.
push
(
path
);
}
else
{
dir
=
fs
.
absolute
(
requireDir
);
while
(
dir
!==
''
)
{
// nodejs compatibility
paths
.
push
(
fs
.
pathJoin
(
dir
,
'node_modules'
,
path
));
dir
=
fs
.
dirname
(
dir
);
}
paths
.
push
(
fs
.
pathJoin
(
requireDir
,
'lib'
,
path
));
paths
.
push
(
fs
.
pathJoin
(
requireDir
,
'modules'
,
path
));
}
paths
.
forEach
(
function
(
testPath
)
{
fileGuesses
.
push
.
apply
(
fileGuesses
,
[
testPath
,
testPath
+
'.js'
,
testPath
+
'.coffee'
,
fs
.
pathJoin
(
testPath
,
'index.js'
),
fs
.
pathJoin
(
testPath
,
'index.coffee'
),
fs
.
pathJoin
(
testPath
,
'lib'
,
fs
.
basename
(
testPath
)
+
'.js'
),
fs
.
pathJoin
(
testPath
,
'lib'
,
fs
.
basename
(
testPath
)
+
'.coffee'
)
]);
});
file
=
null
;
for
(
i
=
0
;
i
<
fileGuesses
.
length
&&
!
file
;
++
i
)
{
if
(
fs
.
isFile
(
fileGuesses
[
i
]))
{
file
=
fileGuesses
[
i
];
}
}
if
(
!
file
)
{
throw
new
Error
(
"CasperJS couldn't find module "
+
path
);
dir
=
fs
.
absolute
(
requireDir
);
while
(
dir
!==
''
)
{
// nodejs compatibility
paths
.
push
(
fs
.
pathJoin
(
dir
,
'node_modules'
,
path
));
dir
=
fs
.
dirname
(
dir
);
}
if
(
file
in
requireCache
)
{
return
requireCache
[
file
].
exports
;
}
try
{
var
scriptCode
=
phantom
.
getScriptCode
(
file
);
new
Function
(
'module'
,
'exports'
,
scriptCode
)(
module
,
module
.
exports
);
}
catch
(
e
)
{
phantom
.
processScriptError
(
e
,
file
);
paths
.
push
(
fs
.
pathJoin
(
requireDir
,
'lib'
,
path
));
paths
.
push
(
fs
.
pathJoin
(
requireDir
,
'modules'
,
path
));
}
paths
.
forEach
(
function
(
testPath
)
{
fileGuesses
.
push
.
apply
(
fileGuesses
,
[
testPath
,
testPath
+
'.js'
,
testPath
+
'.coffee'
,
fs
.
pathJoin
(
testPath
,
'index.js'
),
fs
.
pathJoin
(
testPath
,
'index.coffee'
),
fs
.
pathJoin
(
testPath
,
'lib'
,
fs
.
basename
(
testPath
)
+
'.js'
),
fs
.
pathJoin
(
testPath
,
'lib'
,
fs
.
basename
(
testPath
)
+
'.coffee'
)
]);
});
file
=
null
;
for
(
i
=
0
;
i
<
fileGuesses
.
length
&&
!
file
;
++
i
)
{
if
(
fs
.
isFile
(
fileGuesses
[
i
]))
{
file
=
fileGuesses
[
i
];
}
requireCache
[
file
]
=
module
;
return
module
.
exports
;
}
if
(
!
file
)
{
throw
new
Error
(
"CasperJS couldn't find module "
+
path
);
}
if
(
file
in
requireCache
)
{
return
requireCache
[
file
].
exports
;
}
try
{
var
scriptCode
=
phantom
.
getScriptCode
(
file
);
new
Function
(
'module'
,
'exports'
,
scriptCode
)(
module
,
module
.
exports
);
}
catch
(
e
)
{
phantom
.
processScriptError
(
e
,
file
);
}
requireCache
[
file
]
=
module
;
return
module
.
exports
;
};
})(
require
,
phantom
.
casperPath
);
...
...
Please
register
or
sign in
to post a comment