config 1.29.1 → 1.30.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/History.md +20 -0
- package/README.md +1 -1
- package/lib/config.js +38 -23
- package/package.json +1 -1
package/History.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
1.30.0 / 2018-02-26
|
|
2
|
+
===================
|
|
3
|
+
|
|
4
|
+
* Support for nested raw() in javascript configurations - patrickpilch
|
|
5
|
+
|
|
6
|
+
1.29.4 / 2018-02-03
|
|
7
|
+
===================
|
|
8
|
+
|
|
9
|
+
* Re-publish - last changes didn't make it to npm
|
|
10
|
+
|
|
11
|
+
1.29.3 / 2018-02-03
|
|
12
|
+
===================
|
|
13
|
+
|
|
14
|
+
* Added soft dependencies so transpilers don't include everything - gewentao
|
|
15
|
+
|
|
16
|
+
1.29.2 / 2018-01-12
|
|
17
|
+
===================
|
|
18
|
+
|
|
19
|
+
* Patch, and added a test to ts-node - electroma
|
|
20
|
+
|
|
1
21
|
1.29.1 / 2018-01-07
|
|
2
22
|
===================
|
|
3
23
|
|
package/README.md
CHANGED
|
@@ -162,8 +162,8 @@ Contributors
|
|
|
162
162
|
<td><img src=https://avatars2.githubusercontent.com/u/54934?v=4><a href="https://github.com/wmertens">wmertens</a></td>
|
|
163
163
|
<td><img src=https://avatars3.githubusercontent.com/u/2842176?v=4><a href="https://github.com/XadillaX">XadillaX</a></td>
|
|
164
164
|
<td><img src=https://avatars1.githubusercontent.com/u/4425455?v=4><a href="https://github.com/ncuillery">ncuillery</a></td>
|
|
165
|
+
<td><img src=https://avatars0.githubusercontent.com/u/2015295?v=4><a href="https://github.com/patrickpilch">patrickpilch</a></td>
|
|
165
166
|
<td><img src=https://avatars1.githubusercontent.com/u/618330?v=4><a href="https://github.com/adityabansod">adityabansod</a></td>
|
|
166
|
-
<td><img src=https://avatars3.githubusercontent.com/u/270632?v=4><a href="https://github.com/thetalecrafter">thetalecrafter</a></td>
|
|
167
167
|
</tr></table>
|
|
168
168
|
|
|
169
169
|
License
|
package/lib/config.js
CHANGED
|
@@ -32,6 +32,19 @@ var DEFAULT_CLONE_DEPTH = 20,
|
|
|
32
32
|
checkMutability = true, // Check for mutability/immutability on first get
|
|
33
33
|
gitCryptTestRegex = /^.GITCRYPT/; // regular expression to test for gitcrypt files.
|
|
34
34
|
|
|
35
|
+
// Define soft dependencies so transpilers don't include everything
|
|
36
|
+
var COFFEE_DEP = "coffee-script",
|
|
37
|
+
ICED_DEP = "iced-coffee-script",
|
|
38
|
+
JS_YAML_DEP = "js-yaml",
|
|
39
|
+
YAML_DEP = "yaml",
|
|
40
|
+
JSON5_DEP = "json5",
|
|
41
|
+
HJSON_DEP = "hjson",
|
|
42
|
+
TOML_DEP = "toml",
|
|
43
|
+
CSON_DEP = "cson",
|
|
44
|
+
PPARSER_DEP = "properties",
|
|
45
|
+
XML_DEP = "x2js",
|
|
46
|
+
TS_DEP = "ts-node";
|
|
47
|
+
|
|
35
48
|
/**
|
|
36
49
|
* <p>Application Configurations</p>
|
|
37
50
|
*
|
|
@@ -173,13 +186,6 @@ Config.prototype.get = function(property) {
|
|
|
173
186
|
if(property === null || property === undefined){
|
|
174
187
|
throw new Error("Calling config.get with null or undefined argument");
|
|
175
188
|
}
|
|
176
|
-
var t = this,
|
|
177
|
-
value = getImpl(t, property);
|
|
178
|
-
|
|
179
|
-
// Produce an exception if the property doesn't exist
|
|
180
|
-
if (value === undefined) {
|
|
181
|
-
throw new Error('Configuration property "' + property + '" is not defined');
|
|
182
|
-
}
|
|
183
189
|
|
|
184
190
|
// Make configurations immutable after first get (unless disabled)
|
|
185
191
|
if (checkMutability) {
|
|
@@ -188,9 +194,12 @@ Config.prototype.get = function(property) {
|
|
|
188
194
|
}
|
|
189
195
|
checkMutability = false;
|
|
190
196
|
}
|
|
197
|
+
var t = this,
|
|
198
|
+
value = getImpl(t, property);
|
|
191
199
|
|
|
192
|
-
if
|
|
193
|
-
|
|
200
|
+
// Produce an exception if the property doesn't exist
|
|
201
|
+
if (value === undefined) {
|
|
202
|
+
throw new Error('Configuration property "' + property + '" is not defined');
|
|
194
203
|
}
|
|
195
204
|
|
|
196
205
|
// Return the value
|
|
@@ -539,7 +548,13 @@ util.makeImmutable = function(object, property, value) {
|
|
|
539
548
|
var propertyName = properties[i],
|
|
540
549
|
value = object[propertyName];
|
|
541
550
|
|
|
542
|
-
if (
|
|
551
|
+
if (value instanceof RawConfig) {
|
|
552
|
+
Object.defineProperty(object, propertyName, {
|
|
553
|
+
value: value.resolve(),
|
|
554
|
+
writable: false,
|
|
555
|
+
configurable: false
|
|
556
|
+
});
|
|
557
|
+
} else {
|
|
543
558
|
Object.defineProperty(object, propertyName, {
|
|
544
559
|
value: value,
|
|
545
560
|
writable : false,
|
|
@@ -875,8 +890,8 @@ util.parseFile = function(fullFilename) {
|
|
|
875
890
|
configObject = require(fullFilename);
|
|
876
891
|
}
|
|
877
892
|
else if (extension === 'ts') {
|
|
878
|
-
if (!require.extensions['ts']) {
|
|
879
|
-
require(
|
|
893
|
+
if (!require.extensions['.ts']) {
|
|
894
|
+
require(TS_DEP).register({
|
|
880
895
|
lazy: true,
|
|
881
896
|
compilerOptions: {
|
|
882
897
|
allowJs: true,
|
|
@@ -904,7 +919,7 @@ util.parseFile = function(fullFilename) {
|
|
|
904
919
|
// Coffee = require("coffee-script");
|
|
905
920
|
//}
|
|
906
921
|
|
|
907
|
-
Coffee = require(
|
|
922
|
+
Coffee = require(COFFEE_DEP);
|
|
908
923
|
|
|
909
924
|
// coffee-script >= 1.7.0 requires explicit registration for require() to work
|
|
910
925
|
if (Coffee.register) {
|
|
@@ -915,7 +930,7 @@ util.parseFile = function(fullFilename) {
|
|
|
915
930
|
configObject = require(fullFilename);
|
|
916
931
|
}
|
|
917
932
|
else if (extension === 'iced') {
|
|
918
|
-
Iced = require(
|
|
933
|
+
Iced = require(ICED_DEP);
|
|
919
934
|
|
|
920
935
|
// coffee-script >= 1.7.0 requires explicit registration for require() to work
|
|
921
936
|
if (Iced.register) {
|
|
@@ -981,12 +996,12 @@ util.parseString = function (content, format) {
|
|
|
981
996
|
// Lazy loading
|
|
982
997
|
try {
|
|
983
998
|
// Try to load the better js-yaml module
|
|
984
|
-
Yaml = require(
|
|
999
|
+
Yaml = require(JS_YAML_DEP);
|
|
985
1000
|
}
|
|
986
1001
|
catch (e) {
|
|
987
1002
|
try {
|
|
988
1003
|
// If it doesn't exist, load the fallback visionmedia yaml module.
|
|
989
|
-
VisionmediaYaml = require(
|
|
1004
|
+
VisionmediaYaml = require(YAML_DEP);
|
|
990
1005
|
}
|
|
991
1006
|
catch (e) { }
|
|
992
1007
|
}
|
|
@@ -1017,7 +1032,7 @@ util.parseString = function (content, format) {
|
|
|
1017
1032
|
}
|
|
1018
1033
|
|
|
1019
1034
|
if (!JSON5) {
|
|
1020
|
-
JSON5 = require(
|
|
1035
|
+
JSON5 = require(JSON5_DEP);
|
|
1021
1036
|
}
|
|
1022
1037
|
|
|
1023
1038
|
configObject = JSON5.parse(content);
|
|
@@ -1026,7 +1041,7 @@ util.parseString = function (content, format) {
|
|
|
1026
1041
|
else if (format === 'json5') {
|
|
1027
1042
|
|
|
1028
1043
|
if (!JSON5) {
|
|
1029
|
-
JSON5 = require(
|
|
1044
|
+
JSON5 = require(JSON5_DEP);
|
|
1030
1045
|
}
|
|
1031
1046
|
|
|
1032
1047
|
configObject = JSON5.parse(content);
|
|
@@ -1034,7 +1049,7 @@ util.parseString = function (content, format) {
|
|
|
1034
1049
|
} else if (format === 'hjson') {
|
|
1035
1050
|
|
|
1036
1051
|
if (!HJSON) {
|
|
1037
|
-
HJSON = require(
|
|
1052
|
+
HJSON = require(HJSON_DEP);
|
|
1038
1053
|
}
|
|
1039
1054
|
|
|
1040
1055
|
configObject = HJSON.parse(content);
|
|
@@ -1042,14 +1057,14 @@ util.parseString = function (content, format) {
|
|
|
1042
1057
|
} else if (format === 'toml') {
|
|
1043
1058
|
|
|
1044
1059
|
if(!TOML) {
|
|
1045
|
-
TOML = require(
|
|
1060
|
+
TOML = require(TOML_DEP);
|
|
1046
1061
|
}
|
|
1047
1062
|
|
|
1048
1063
|
configObject = TOML.parse(content);
|
|
1049
1064
|
}
|
|
1050
1065
|
else if (format === 'cson') {
|
|
1051
1066
|
if (!CSON) {
|
|
1052
|
-
CSON = require(
|
|
1067
|
+
CSON = require(CSON_DEP);
|
|
1053
1068
|
}
|
|
1054
1069
|
// Allow comments in CSON files
|
|
1055
1070
|
if (typeof CSON.parseSync === 'function') {
|
|
@@ -1060,13 +1075,13 @@ util.parseString = function (content, format) {
|
|
|
1060
1075
|
}
|
|
1061
1076
|
else if (format === 'properties') {
|
|
1062
1077
|
if (!PPARSER) {
|
|
1063
|
-
PPARSER = require(
|
|
1078
|
+
PPARSER = require(PPARSER_DEP);
|
|
1064
1079
|
}
|
|
1065
1080
|
configObject = PPARSER.parse(content, { namespaces: true, variables: true, sections: true });
|
|
1066
1081
|
} else if (format === 'xml') {
|
|
1067
1082
|
|
|
1068
1083
|
if (!XML) {
|
|
1069
|
-
XML = require(
|
|
1084
|
+
XML = require(XML_DEP);
|
|
1070
1085
|
}
|
|
1071
1086
|
|
|
1072
1087
|
var x2js = new XML();
|