1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | function accesorString(value) {
|
7 | var childProperties = value.split(".");
|
8 | var length = childProperties.length;
|
9 | var propertyString = "global";
|
10 | var result = "";
|
11 |
|
12 | for(var i = 0; i < length; i++) {
|
13 | if(i > 0)
|
14 | result += "if(!" + propertyString + ") " + propertyString + " = {};\n";
|
15 | propertyString += "[" + JSON.stringify(childProperties[i]) + "]";
|
16 | }
|
17 |
|
18 | result += "module.exports = " + propertyString;
|
19 | return result;
|
20 | }
|
21 |
|
22 | module.exports = function() {};
|
23 | module.exports.pitch = function(remainingRequest) {
|
24 | this.cacheable && this.cacheable();
|
25 | if(!this.query) throw new Error("query parameter is missing");
|
26 | return accesorString(this.query.substr(1)) + " = " +
|
27 | "require(" + JSON.stringify("-!" + remainingRequest) + ");";
|
28 | };
|