File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change 4
4
*/
5
5
6
6
function accesorString ( value ) {
7
- var depths = value . split ( "." ) ;
8
- var length = depths . length ;
7
+ var childProperties = value . split ( "." ) ;
8
+ var length = childProperties . length ;
9
+ var propertyString = "global" ;
9
10
var result = "" ;
10
-
11
- for ( var i = 0 ; i < length ; i ++ ) {
12
- result += "[" + JSON . stringify ( depths [ i ] ) + "]" ;
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 ] ) + "]" ;
13
16
}
14
17
18
+ result += "module.exports = " + propertyString ;
15
19
return result ;
16
20
}
17
21
18
22
module . exports = function ( ) { } ;
19
23
module . exports . pitch = function ( remainingRequest ) {
20
24
this . cacheable && this . cacheable ( ) ;
21
25
if ( ! this . query ) throw new Error ( "query parameter is missing" ) ;
22
- return "module.exports = " +
23
- "global" + accesorString ( this . query . substr ( 1 ) ) + " = " +
26
+ return accesorString ( this . query . substr ( 1 ) ) + " = " +
24
27
"require(" + JSON . stringify ( "-!" + remainingRequest ) + ");" ;
25
- } ;
28
+ } ;
You can’t perform that action at this time.
0 commit comments