pixl-config 1.0.10 → 1.0.13
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/config.js +22 -10
- package/package.json +2 -2
package/config.js
CHANGED
|
@@ -164,6 +164,11 @@ var Config = module.exports = Class.create({
|
|
|
164
164
|
if (this.args) this.args.set(key, value);
|
|
165
165
|
},
|
|
166
166
|
|
|
167
|
+
delete: function(key) {
|
|
168
|
+
// delete config key
|
|
169
|
+
delete this.config[key];
|
|
170
|
+
},
|
|
171
|
+
|
|
167
172
|
import: function(hash) {
|
|
168
173
|
// import all keys/values from specified hash (shallow copy)
|
|
169
174
|
Tools.mergeHashInto( this.config, hash );
|
|
@@ -204,6 +209,14 @@ var Config = module.exports = Class.create({
|
|
|
204
209
|
|
|
205
210
|
getHostname: function(callback) {
|
|
206
211
|
// determine server hostname
|
|
212
|
+
this.hostname = this.get('hostname');
|
|
213
|
+
if (this.hostname) {
|
|
214
|
+
// well that was easy
|
|
215
|
+
callback();
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// try ENV vars next
|
|
207
220
|
this.hostname = (process.env['HOSTNAME'] || process.env['HOST'] || '').toLowerCase();
|
|
208
221
|
if (this.hostname) {
|
|
209
222
|
// well that was easy
|
|
@@ -234,9 +247,16 @@ var Config = module.exports = Class.create({
|
|
|
234
247
|
// determine server ip address
|
|
235
248
|
var self = this;
|
|
236
249
|
|
|
237
|
-
//
|
|
250
|
+
// allow the config to override this
|
|
251
|
+
this.ip = this.get('ip');
|
|
252
|
+
if (this.ip) {
|
|
253
|
+
// well that was easy
|
|
254
|
+
callback();
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// try OS networkInterfaces()
|
|
238
259
|
// find the first external IPv4 address that doesn't match 169.254.*
|
|
239
|
-
// (and preferably not 172.* either)
|
|
240
260
|
var ifaces = os.networkInterfaces();
|
|
241
261
|
var addrs = [];
|
|
242
262
|
for (var key in ifaces) {
|
|
@@ -248,14 +268,6 @@ var Config = module.exports = Class.create({
|
|
|
248
268
|
var iaddrs = Tools.findObjects( addrs, { family: 'IPv4', internal: false } );
|
|
249
269
|
for (var idx = 0, len = iaddrs.length; idx < len; idx++) {
|
|
250
270
|
var addr = iaddrs[idx];
|
|
251
|
-
|
|
252
|
-
if (addr && addr.address && addr.address.match(/^\d+\.\d+\.\d+\.\d+$/) && !addr.address.match(/^(169\.254\.|172\.)/)) {
|
|
253
|
-
// found an interface that is not 169.254.* nor 172.* so prefer that
|
|
254
|
-
this.ip = addr.address;
|
|
255
|
-
callback();
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
271
|
if (addr && addr.address && addr.address.match(/^\d+\.\d+\.\d+\.\d+$/) && !addr.address.match(/^169\.254\./)) {
|
|
260
272
|
// found an interface that is not 169.254.* so go with that one
|
|
261
273
|
this.ip = addr.address;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pixl-config",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "A simple JSON configuration loader.",
|
|
5
5
|
"author": "Joseph Huckaby <jhuckaby@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/jhuckaby/pixl-config",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"config"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"pixl-class": "^1.0.
|
|
21
|
+
"pixl-class": "^1.0.3",
|
|
22
22
|
"pixl-args": "^1.0.0",
|
|
23
23
|
"pixl-tools": "^1.0.0"
|
|
24
24
|
},
|