Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

mockery: removed old resolveFilename hack #25

Merged
merged 1 commit into from
Jan 26, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions mockery.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,6 @@ function getEffectiveOptions(opts) {
return options;
}

/*
* The perils of using internal functions. The Node-internal _resolveFilename
* function was changed in commit 840229a8251955d2b791928875f36d35127dcad0
* (just prior to v0.6.10) such that it returns a string, whereas previously
* it returned an array. Instead of playing version number tricks, just check
* for an array and pull the filename from that if necessary.
*/
//TODO Remove this whole method.
function resolveFilename(request, parent) {
var filename = m._resolveFilename(request, parent);
/*istanbul ignore next - This is for node < 0.6 which we don't care about. Can be removed. */
if (Array.isArray(filename)) {
filename = filename[1];
}
return filename;
}

/*
* The (private) loader replacement that is used when hooking is enabled. It
* does the work of returning a mock or substitute when configured, reporting
Expand Down Expand Up @@ -116,8 +99,7 @@ function hookedLoader(request, parent, isMain) {
if (registeredAllowables.hasOwnProperty(request)) {
allow = registeredAllowables[request];
if (allow.unhook) {
/* TODO: Change this to m._resolveFilename */
file = resolveFilename(request, parent);
file = m._resolveFilename(request, parent);
if (file.indexOf('/') !== -1 && allow.paths.indexOf(file) === -1) {
allow.paths.push(file);
}
Expand Down