superconf 1.2.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Legacy.js +216 -0
- package/Superconf.js +257 -0
- package/app.js +23 -0
- package/package.json +23 -15
- package/.eslintrc +0 -3
- package/.gitlab-ci.yml +0 -19
- package/.npmignore +0 -2
- package/.travis.yml +0 -7
- package/index.js +0 -216
- package/package-lock.json +0 -2223
- package/tests/.eslintrc +0 -6
- package/tests/fixtures/.rccsontestrc.cson +0 -3
- package/tests/fixtures/.rcjsontestrc.json +0 -4
- package/tests/fixtures/.rctestrc +0 -5
- package/tests/fixtures/.rcyamltestrc.yaml +0 -2
- package/tests/fixtures/.rcymltestrc.yml +0 -2
- package/tests/fixtures/csontest.cson +0 -3
- package/tests/fixtures/defaultConf.json +0 -4
- package/tests/fixtures/jsontest.json +0 -4
- package/tests/fixtures/package.json +0 -7
- package/tests/fixtures/yamltest.yaml +0 -2
- package/tests/fixtures/ymltest.yml +0 -2
- package/tests/superconf.spec.js +0 -356
package/tests/.eslintrc
DELETED
package/tests/fixtures/.rctestrc
DELETED
package/tests/superconf.spec.js
DELETED
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const path = require('path')
|
|
4
|
-
|
|
5
|
-
const inspect = require('inspect.js')
|
|
6
|
-
const superconf = require('../index.js')
|
|
7
|
-
|
|
8
|
-
process.chdir(path.join(__dirname, '/fixtures/'))
|
|
9
|
-
|
|
10
|
-
describe('Superconf', () => {
|
|
11
|
-
describe('JSON', () => {
|
|
12
|
-
it('Should load a JSON conf', () => {
|
|
13
|
-
let conf = superconf('jsontest')
|
|
14
|
-
inspect(conf).isObject()
|
|
15
|
-
inspect(conf).isEql({
|
|
16
|
-
foo: 'bar',
|
|
17
|
-
bla: 'blub'
|
|
18
|
-
})
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
it('Should load a CSON conf', () => {
|
|
22
|
-
let conf = superconf('csontest')
|
|
23
|
-
inspect(conf).isObject()
|
|
24
|
-
inspect(conf).isEql({
|
|
25
|
-
foo: 'bar',
|
|
26
|
-
bla: 'blub'
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('Should load a YAML conf', () => {
|
|
31
|
-
let conf = superconf('yamltest')
|
|
32
|
-
inspect(conf).isObject()
|
|
33
|
-
inspect(conf).isEql({
|
|
34
|
-
foo: 'bar',
|
|
35
|
-
bla: 'blub'
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('Should load a YML conf', () => {
|
|
40
|
-
let conf = superconf('ymltest')
|
|
41
|
-
inspect(conf).isObject()
|
|
42
|
-
inspect(conf).isEql({
|
|
43
|
-
foo: 'bar',
|
|
44
|
-
bla: 'blub'
|
|
45
|
-
})
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it('Should load a RC file', () => {
|
|
49
|
-
let conf = superconf('rctest')
|
|
50
|
-
inspect(conf).isObject()
|
|
51
|
-
inspect(conf).isEql({
|
|
52
|
-
foo: 'bar',
|
|
53
|
-
bla: 'blub'
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
it('Should load a JSON conf', () => {
|
|
58
|
-
let conf = superconf('rcjsontest')
|
|
59
|
-
inspect(conf).isObject()
|
|
60
|
-
inspect(conf).isEql({
|
|
61
|
-
foo: 'bar',
|
|
62
|
-
bla: 'blub'
|
|
63
|
-
})
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it('Should load a CSON conf', () => {
|
|
67
|
-
let conf = superconf('rccsontest')
|
|
68
|
-
inspect(conf).isObject()
|
|
69
|
-
inspect(conf).isEql({
|
|
70
|
-
foo: 'bar',
|
|
71
|
-
bla: 'blub'
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
it('Should load a YAML conf', () => {
|
|
76
|
-
let conf = superconf('rcyamltest')
|
|
77
|
-
inspect(conf).isObject()
|
|
78
|
-
inspect(conf).isEql({
|
|
79
|
-
foo: 'bar',
|
|
80
|
-
bla: 'blub'
|
|
81
|
-
})
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
it('Should load a YML conf', () => {
|
|
85
|
-
let conf = superconf('rcymltest')
|
|
86
|
-
inspect(conf).isObject()
|
|
87
|
-
inspect(conf).isEql({
|
|
88
|
-
foo: 'bar',
|
|
89
|
-
bla: 'blub'
|
|
90
|
-
})
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
it('Should load a JSON conf', () => {
|
|
94
|
-
let conf = superconf('pkgtest')
|
|
95
|
-
inspect(conf).isObject()
|
|
96
|
-
inspect(conf).isEql({
|
|
97
|
-
foo: 'bar',
|
|
98
|
-
bla: 'blub'
|
|
99
|
-
})
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it('Should load a JSON conf', () => {
|
|
103
|
-
let conf = superconf('pkgtest')
|
|
104
|
-
inspect(conf).isObject()
|
|
105
|
-
inspect(conf).isEql({
|
|
106
|
-
foo: 'bar',
|
|
107
|
-
bla: 'blub'
|
|
108
|
-
})
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
it('Should load a JSON from defaultConf', () => {
|
|
112
|
-
let conf = superconf('defaulttest', {
|
|
113
|
-
defaultConf: path.join(__dirname, './fixtures/defaultConf.json')
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
inspect(conf).isObject()
|
|
117
|
-
inspect(conf).isEql({
|
|
118
|
-
foo: 'bar',
|
|
119
|
-
bla: 'blub'
|
|
120
|
-
})
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
it('Should not load a JSON from defaultConf', () => {
|
|
124
|
-
let conf = superconf('defaulttest')
|
|
125
|
-
|
|
126
|
-
inspect(conf).isNull()
|
|
127
|
-
})
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
describe('merge()', function () {
|
|
131
|
-
it('Should merge object using Object.assign()', function () {
|
|
132
|
-
let left = {
|
|
133
|
-
fruit: 'Apple',
|
|
134
|
-
vegetable: 'Carrot'
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
let right = {
|
|
138
|
-
fruit: 'Banana',
|
|
139
|
-
vegetable: undefined
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
let conf = Object.assign(left, right)
|
|
143
|
-
inspect(conf).isEql({
|
|
144
|
-
fruit: 'Banana',
|
|
145
|
-
vegetable: undefined
|
|
146
|
-
})
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
it('Should merge config objects', function () {
|
|
150
|
-
let left = {
|
|
151
|
-
fruit: 'Apple',
|
|
152
|
-
vegetable: 'Carrot'
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
let right = {
|
|
156
|
-
fruit: 'Banana',
|
|
157
|
-
vegetable: undefined
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
let conf = superconf.merge(left, right)
|
|
161
|
-
inspect(conf).isEql({
|
|
162
|
-
fruit: 'Banana',
|
|
163
|
-
vegetable: 'Carrot'
|
|
164
|
-
})
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
it('Should overwrite objects', function () {
|
|
168
|
-
let left = {
|
|
169
|
-
fruit: 'Apple',
|
|
170
|
-
vegetables: {
|
|
171
|
-
red: 'Tomato',
|
|
172
|
-
green: 'Curcumber',
|
|
173
|
-
blue: 'Red cabbage'
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
let right = {
|
|
178
|
-
fruit: 'Banana',
|
|
179
|
-
vegetables: {
|
|
180
|
-
red: 'Capsicum'
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
let conf = superconf.merge(left, right)
|
|
185
|
-
inspect(conf).isEql({
|
|
186
|
-
fruit: 'Banana',
|
|
187
|
-
vegetables: {
|
|
188
|
-
red: 'Capsicum'
|
|
189
|
-
}
|
|
190
|
-
})
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
it('Should overwrite arrays', function () {
|
|
194
|
-
let left = {
|
|
195
|
-
fruit: 'Apple',
|
|
196
|
-
vegetables: [
|
|
197
|
-
'Tomato',
|
|
198
|
-
'Curcumber',
|
|
199
|
-
'Red cabbage'
|
|
200
|
-
]
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
let right = {
|
|
204
|
-
fruit: 'Banana',
|
|
205
|
-
vegetables: [
|
|
206
|
-
'Capsicum'
|
|
207
|
-
]
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
let conf = superconf.merge(left, right)
|
|
211
|
-
inspect(conf).isEql({
|
|
212
|
-
fruit: 'Banana',
|
|
213
|
-
vegetables: [
|
|
214
|
-
'Capsicum'
|
|
215
|
-
]
|
|
216
|
-
})
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
it('Should merge the first level together', function () {
|
|
220
|
-
let left = {
|
|
221
|
-
fruit: 'Apple',
|
|
222
|
-
vegetables: {
|
|
223
|
-
red: 'Tomato',
|
|
224
|
-
green: 'Curcumber',
|
|
225
|
-
blue: 'Red cabbage'
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
let right = {
|
|
230
|
-
fruit: 'Banana',
|
|
231
|
-
vegetables: {
|
|
232
|
-
red: 'Capsicum'
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
let conf = superconf.config({
|
|
237
|
-
dept: 1
|
|
238
|
-
}).merge(left, right)
|
|
239
|
-
|
|
240
|
-
inspect(conf).isEql({
|
|
241
|
-
fruit: 'Banana',
|
|
242
|
-
vegetables: {
|
|
243
|
-
red: 'Capsicum',
|
|
244
|
-
green: 'Curcumber',
|
|
245
|
-
blue: 'Red cabbage'
|
|
246
|
-
}
|
|
247
|
-
})
|
|
248
|
-
})
|
|
249
|
-
|
|
250
|
-
it('Should merge the first level together, using arrays', function () {
|
|
251
|
-
let left = {
|
|
252
|
-
fruit: 'Apple',
|
|
253
|
-
vegetables: {
|
|
254
|
-
red: [
|
|
255
|
-
'Tomato',
|
|
256
|
-
'Capsicum'
|
|
257
|
-
]
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
let right = {
|
|
262
|
-
fruit: 'Banana',
|
|
263
|
-
vegetables: {
|
|
264
|
-
green: [
|
|
265
|
-
'Curcumber'
|
|
266
|
-
]
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
let conf = superconf.config({
|
|
271
|
-
dept: 1
|
|
272
|
-
}).merge(left, right)
|
|
273
|
-
inspect(conf).isEql({
|
|
274
|
-
fruit: 'Banana',
|
|
275
|
-
vegetables: {
|
|
276
|
-
red: ['Tomato', 'Capsicum'],
|
|
277
|
-
green: ['Curcumber']
|
|
278
|
-
}
|
|
279
|
-
})
|
|
280
|
-
})
|
|
281
|
-
})
|
|
282
|
-
|
|
283
|
-
describe('copy()', () => {
|
|
284
|
-
it('copies a config object', () => {
|
|
285
|
-
const obj = {
|
|
286
|
-
foo: 'foo',
|
|
287
|
-
bar: 'bar',
|
|
288
|
-
bla: {
|
|
289
|
-
blub: 123
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
const copied = superconf.copy(obj)
|
|
294
|
-
inspect(copied).isEql(obj)
|
|
295
|
-
inspect(copied).isNotEqual(obj)
|
|
296
|
-
inspect(copied.bla).isNotEqual(obj.bla)
|
|
297
|
-
})
|
|
298
|
-
|
|
299
|
-
it('copies a config object with an array', () => {
|
|
300
|
-
const three = {
|
|
301
|
-
number: {
|
|
302
|
-
digit: 3
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
const obj = {
|
|
307
|
-
foo: 'foo',
|
|
308
|
-
bar: 'bar',
|
|
309
|
-
bla: [
|
|
310
|
-
'one',
|
|
311
|
-
'zwo',
|
|
312
|
-
three
|
|
313
|
-
]
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
const copied = superconf.copy(obj)
|
|
317
|
-
inspect(copied).isEql(obj)
|
|
318
|
-
inspect(copied).isNotEqual(obj)
|
|
319
|
-
inspect(copied.bla).isArray().hasLength(3)
|
|
320
|
-
inspect(copied.bla).isNotEqual(obj.bla)
|
|
321
|
-
inspect(copied.bla[2]).isEql(three).isNotEqual(three)
|
|
322
|
-
})
|
|
323
|
-
|
|
324
|
-
it('copies a config object with all existing shit', () => {
|
|
325
|
-
const three = {
|
|
326
|
-
number: {
|
|
327
|
-
digit: 3,
|
|
328
|
-
str: 'three',
|
|
329
|
-
used: null,
|
|
330
|
-
none: undefined
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
const obj = {
|
|
335
|
-
foo: 'foo',
|
|
336
|
-
bar: 'bar',
|
|
337
|
-
bla: [
|
|
338
|
-
'one',
|
|
339
|
-
'zwo',
|
|
340
|
-
three,
|
|
341
|
-
123,
|
|
342
|
-
null,
|
|
343
|
-
undefined,
|
|
344
|
-
['sub-one']
|
|
345
|
-
]
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
const copied = superconf.copy(obj)
|
|
349
|
-
inspect(copied).isEql(obj)
|
|
350
|
-
inspect(copied).isNotEqual(obj)
|
|
351
|
-
inspect(copied.bla).isArray().hasLength(7)
|
|
352
|
-
inspect(copied.bla).isNotEqual(obj.bla)
|
|
353
|
-
inspect(copied.bla[2]).isEql(three).isNotEqual(three)
|
|
354
|
-
})
|
|
355
|
-
})
|
|
356
|
-
})
|