Index: lib/api.js |
=================================================================== |
--- a/lib/api.js |
+++ b/lib/api.js |
@@ -162,6 +162,52 @@ |
forceUpdateCheck: function(eventName) |
{ |
checkForUpdates(true, _triggerEvent.bind(null, eventName)); |
+ }, |
+ |
+ getRequire: function(requireName) |
+ { |
+ // Just go 2 levels deep to avoid cycles |
+ var module = require.scopes[requireName]; |
+ var requireString = "{"; |
+ for (var prop in module) |
+ { |
+ if (typeof(module[prop]) == "object") |
+ { |
+ requireString += prop + ": "; |
+ } |
+ else if ((typeof(module[prop]) == "function") || (module[prop] == null)) |
+ { |
+ requireString += prop + ": " + module[prop]; |
+ } |
+ else |
+ { |
+ requireString += prop + ": \"" + module[prop] + "\""; |
+ } |
+ var hasSubProperties = false |
+ if (typeof(module[prop]) == "object") |
+ { |
+ requireString += " {"; |
+ for (var innerProp in module[prop]) |
+ { |
+ if ((typeof(module[prop][innerProp]) == "function") || (module[prop][innerProp] == null)) |
+ { |
+ requireString += innerProp + ": " + module[prop][innerProp] + ","; |
+ } |
+ else |
+ { |
+ requireString += innerProp + ": \"" + module[prop][innerProp] + "\","; |
+ } |
+ } |
+ requireString = requireString.replace(/,+$/, ""); |
+ requireString += "}"; |
+ } |
+ requireString += ","; |
+ } |
+ requireString = requireString.replace(/,+$/, ""); |
+ requireString += "}"; |
+ requireString = requireString.replace(/(\r\n|\n|\r)/gm, ""); |
+ return requireString; |
} |
+ |
}; |
})(); |