File tree 2 files changed +34
-2
lines changed
2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -86,8 +86,8 @@ export class Context {
86
86
}
87
87
88
88
public everything ( ) : { [ key : string ] : any } {
89
- const b = this . bottom . get ( this . bottomPrefixPath ) ;
90
- const t = this . top . get ( [ ] ) ;
89
+ const b = this . bottom . get ( this . bottomPrefixPath ) || { } ;
90
+ const t = this . top . get ( [ ] ) || { } ;
91
91
return Object . assign ( b , t ) ;
92
92
}
93
93
Original file line number Diff line number Diff line change @@ -110,4 +110,36 @@ export = {
110
110
111
111
test . done ( ) ;
112
112
} ,
113
+
114
+ async 'surive missing new file' ( test : Test ) {
115
+ // GIVEN
116
+ await fs . writeJSON ( 'cdk.json' , { context : { boo : 'far' } } ) ;
117
+ const config = await new Configuration ( ) . load ( ) ;
118
+
119
+ // WHEN
120
+ test . deepEqual ( config . context . everything ( ) , { boo : 'far' } ) ;
121
+ await config . saveContext ( ) ;
122
+
123
+ // THEN
124
+ test . deepEqual ( await fs . readJSON ( 'cdk.context.json' ) , { } ) ;
125
+ test . deepEqual ( await fs . readJSON ( 'cdk.json' ) , { context : { boo : 'far' } } ) ;
126
+
127
+ test . done ( ) ;
128
+ } ,
129
+
130
+ async 'surive no context in old file' ( test : Test ) {
131
+ // GIVEN
132
+ await fs . writeJSON ( 'cdk.json' , { } ) ;
133
+ await fs . writeJSON ( 'cdk.context.json' , { boo : 'far' } ) ;
134
+ const config = await new Configuration ( ) . load ( ) ;
135
+
136
+ // WHEN
137
+ test . deepEqual ( config . context . everything ( ) , { boo : 'far' } ) ;
138
+ await config . saveContext ( ) ;
139
+
140
+ // THEN
141
+ test . deepEqual ( await fs . readJSON ( 'cdk.context.json' ) , { boo : 'far' } ) ;
142
+
143
+ test . done ( ) ;
144
+ } ,
113
145
} ;
You can’t perform that action at this time.
0 commit comments