Browse files

Fixed problems with null config values, bumped version

  • Loading branch information...
1 parent b946411 commit 44c1b47bb4be64482bb32f1be2e29d5ddb5452a0 Loren West committed Jun 1, 2012
View
4 History.md
@@ -1,9 +1,11 @@
-0.4.14 / 2012-04-27
+0.4.14 / 2012-06-01
===================
* Added the local.EXT and local-deployment.EXT configs.
* Removed unnecessary debug output
* Added retry logic on file parse to reduce read/write collisions
+ * Added support for a better YAML parser
+ * Fixed problems with null configuration values
0.4.13 / 2012-04-25
===================
View
12 doc/1-protected-test.js.html
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>test 1-protected-test.js </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1335400935.57" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1335400935.57" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1338535530.96" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1338535530.96" />
- <script type="text/javascript" src="assets/api-js?stamp=1335400935.57"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1335400935.57"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1338535530.96"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1338535530.96"></script>
</head>
<body id="node-monitor">
@@ -88,6 +88,8 @@
<span class="nx">assert</span><span class="p">.</span><span class="nx">isFalse</span><span class="p">(</span><span class="nx">CONFIG</span><span class="p">.</span><span class="nx">_isObject</span><span class="p">(</span><span class="mi">45</span><span class="p">));</span>
<span class="nx">assert</span><span class="p">.</span><span class="nx">isFalse</span><span class="p">(</span><span class="nx">CONFIG</span><span class="p">.</span><span class="nx">_isObject</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]));</span>
<span class="nx">assert</span><span class="p">.</span><span class="nx">isFalse</span><span class="p">(</span><span class="nx">CONFIG</span><span class="p">.</span><span class="nx">_isObject</span><span class="p">([</span><span class="s2">&quot;a&quot;</span><span class="p">,</span> <span class="s2">&quot;b&quot;</span><span class="p">]));</span>
+ <span class="nx">assert</span><span class="p">.</span><span class="nx">isFalse</span><span class="p">(</span><span class="nx">CONFIG</span><span class="p">.</span><span class="nx">_isObject</span><span class="p">(</span><span class="kc">null</span><span class="p">));</span>
+ <span class="nx">assert</span><span class="p">.</span><span class="nx">isFalse</span><span class="p">(</span><span class="nx">CONFIG</span><span class="p">.</span><span class="nx">_isObject</span><span class="p">(</span><span class="kc">undefined</span><span class="p">));</span>
<span class="p">}</span>
<span class="p">},</span>
@@ -416,7 +418,7 @@
<div id="ft">
<hr />
Released on <a href="https://github.com/lorenwest/node-config">github</a> under the <a href="https://github.com/lorenwest/node-config/blob/master/LICENSE">Apache License 2.0</a>
-<span class="subtitle">version 0.4.13</span>
+<span class="subtitle">version 0.4.14</span>
</div>
</div>
<script type="text/javascript">
View
22 doc/2-config-test.js.html
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>test 2-config-test.js </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1335400935.57" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1335400935.57" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1338535530.96" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1338535530.96" />
- <script type="text/javascript" src="assets/api-js?stamp=1335400935.57"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1335400935.57"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1338535530.96"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1338535530.96"></script>
</head>
<body id="node-monitor">
@@ -97,6 +97,18 @@
<span class="nx">assert</span><span class="p">.</span><span class="nx">equal</span><span class="p">(</span><span class="nx">CONFIG</span><span class="p">.</span><span class="nx">AnotherModule</span><span class="p">.</span><span class="nx">parm3</span><span class="p">,</span> <span class="s1">&#39;value3&#39;</span><span class="p">);</span>
<span class="p">},</span>
+ <span class="s1">&#39;Loading configurations from an environment file is correct&#39;</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
+ <span class="nx">assert</span><span class="p">.</span><span class="nx">equal</span><span class="p">(</span><span class="nx">CONFIG</span><span class="p">.</span><span class="nx">Customers</span><span class="p">.</span><span class="nx">dbPort</span><span class="p">,</span> <span class="s1">&#39;5999&#39;</span><span class="p">);</span>
+ <span class="p">},</span>
+
+ <span class="s1">&#39;Loading configurations from the local file is correct&#39;</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
+ <span class="nx">assert</span><span class="p">.</span><span class="nx">equal</span><span class="p">(</span><span class="nx">CONFIG</span><span class="p">.</span><span class="nx">Customers</span><span class="p">.</span><span class="nx">dbPassword</span><span class="p">,</span> <span class="s1">&#39;real password&#39;</span><span class="p">);</span>
+ <span class="p">},</span>
+
+ <span class="s1">&#39;Loading configurations from the local environment file is correct&#39;</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
+ <span class="nx">assert</span><span class="p">.</span><span class="nx">equal</span><span class="p">(</span><span class="nx">CONFIG</span><span class="p">.</span><span class="nx">Customers</span><span class="p">.</span><span class="nx">dbPassword2</span><span class="p">,</span> <span class="s1">&#39;another password&#39;</span><span class="p">);</span>
+ <span class="p">},</span>
+
<span class="s1">&#39;Loading prior runtime.json configurations is correct&#39;</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="nx">assert</span><span class="p">.</span><span class="nx">equal</span><span class="p">(</span><span class="nx">CONFIG</span><span class="p">.</span><span class="nx">Customers</span><span class="p">.</span><span class="nx">dbName</span><span class="p">,</span> <span class="s1">&#39;override_from_runtime_json&#39;</span><span class="p">);</span>
<span class="p">}</span>
@@ -302,7 +314,7 @@
<div id="ft">
<hr />
Released on <a href="https://github.com/lorenwest/node-config">github</a> under the <a href="https://github.com/lorenwest/node-config/blob/master/LICENSE">Apache License 2.0</a>
-<span class="subtitle">version 0.4.13</span>
+<span class="subtitle">version 0.4.14</span>
</div>
</div>
<script type="text/javascript">
View
12 doc/Config.html
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>config Config </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1335400935.6" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1335400935.6" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1338535530.99" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1338535530.99" />
- <script type="text/javascript" src="assets/api-js?stamp=1335400935.6"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1335400935.6"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1338535530.99"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1338535530.99"></script>
</head>
<body id="node-monitor">
@@ -530,6 +530,8 @@ <h3 id="methods">Methods</h3>
(hostname).EXT
(deployment).EXT
(hostname)-(deployment).EXT
+local.EXT
+local-(deployment).EXT
runtime.json
</pre>
<p>
@@ -1356,7 +1358,7 @@ <h3 id="methods">Methods</h3>
<div id="ft">
<hr />
Released on <a href="https://github.com/lorenwest/node-config">github</a> under the <a href="https://github.com/lorenwest/node-config/blob/master/LICENSE">Apache License 2.0</a>
-<span class="subtitle">version 0.4.13</span>
+<span class="subtitle">version 0.4.14</span>
</div>
</div>
<script type="text/javascript">
View
10 doc/ConfigTest.html
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>test ConfigTest </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1335400935.57" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1335400935.57" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1338535530.96" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1338535530.96" />
- <script type="text/javascript" src="assets/api-js?stamp=1335400935.57"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1335400935.57"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1338535530.96"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1338535530.96"></script>
</head>
<body id="node-monitor">
@@ -120,7 +120,7 @@
<div id="ft">
<hr />
Released on <a href="https://github.com/lorenwest/node-config">github</a> under the <a href="https://github.com/lorenwest/node-config/blob/master/LICENSE">Apache License 2.0</a>
-<span class="subtitle">version 0.4.13</span>
+<span class="subtitle">version 0.4.14</span>
</div>
</div>
<script type="text/javascript">
View
10 doc/ProtectedTest.html
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>test ProtectedTest </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1335400935.57" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1335400935.57" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1338535530.96" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1338535530.96" />
- <script type="text/javascript" src="assets/api-js?stamp=1335400935.57"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1335400935.57"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1338535530.96"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1338535530.96"></script>
</head>
<body id="node-monitor">
@@ -120,7 +120,7 @@
<div id="ft">
<hr />
Released on <a href="https://github.com/lorenwest/node-config">github</a> under the <a href="https://github.com/lorenwest/node-config/blob/master/LICENSE">Apache License 2.0</a>
-<span class="subtitle">version 0.4.13</span>
+<span class="subtitle">version 0.4.14</span>
</div>
</div>
<script type="text/javascript">
View
73 doc/config.js.html
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>config config.js </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1335400935.6" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1335400935.6" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1338535530.99" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1338535530.99" />
- <script type="text/javascript" src="assets/api-js?stamp=1335400935.6"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1335400935.6"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1338535530.99"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1338535530.99"></script>
</head>
<body id="node-monitor">
@@ -49,7 +49,8 @@
<div class="highlight"><pre><span class="cm">/*jsl:declare global */</span>
<span class="c1">// Dependencies</span>
<span class="kd">var</span> <span class="nx">Yaml</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// External libraries are lazy-loaded</span>
- <span class="nx">Coffee</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// only if these file types exist.</span>
+ <span class="nx">VisionmediaYaml</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span> <span class="c1">// only if these file types exist.</span>
+ <span class="nx">Coffee</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span>
<span class="nx">FileSystem</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;fs&#39;</span><span class="p">);</span>
<span class="c1">// Static members</span>
@@ -277,7 +278,7 @@
<span class="nx">o</span><span class="p">.</span><span class="nx">__watchers</span><span class="p">[</span><span class="nx">prop</span><span class="p">].</span><span class="nx">push</span><span class="p">(</span><span class="nx">handler</span><span class="p">);</span>
<span class="c1">// Recurs if this is an object...</span>
- <span class="k">if</span> <span class="p">(</span><span class="k">typeof</span><span class="p">(</span><span class="nx">o</span><span class="p">[</span><span class="nx">prop</span><span class="p">])</span> <span class="o">==</span> <span class="s1">&#39;object&#39;</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">o</span><span class="p">[</span><span class="nx">prop</span><span class="p">]</span> <span class="o">&amp;&amp;</span> <span class="k">typeof</span><span class="p">(</span><span class="nx">o</span><span class="p">[</span><span class="nx">prop</span><span class="p">])</span> <span class="o">==</span> <span class="s1">&#39;object&#39;</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">Config</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">watch</span><span class="p">(</span><span class="nx">o</span><span class="p">[</span><span class="nx">prop</span><span class="p">],</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">handler</span><span class="p">,</span> <span class="nx">depth</span> <span class="o">-</span> <span class="mi">1</span><span class="p">);</span>
<span class="p">}</span>
@@ -482,7 +483,7 @@
<span class="k">if</span> <span class="p">(</span><span class="nx">interval</span> <span class="o">===</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span><span class="k">return</span><span class="p">;}</span>
<span class="c1">// Re-merge the runtime JSON file if we notice a change</span>
- <span class="kd">var</span> <span class="nx">onFileChange</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">onFileChange</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">retry</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">FileSystem</span><span class="p">.</span><span class="nx">readFile</span><span class="p">(</span><span class="nx">runtimeJsonFilename</span><span class="p">,</span> <span class="s1">&#39;UTF-8&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">fileContent</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// Not much to do on error</span>
@@ -498,6 +499,12 @@
<span class="nx">t</span><span class="p">.</span><span class="nx">_extendDeep</span><span class="p">(</span><span class="nx">t</span><span class="p">,</span> <span class="nx">configObject</span><span class="p">);</span>
<span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s2">&quot;Error parsing &quot;</span> <span class="o">+</span> <span class="nx">runtimeJsonFilename</span><span class="p">,</span> <span class="nx">e</span><span class="p">);</span>
+ <span class="c1">// Retry once - could be someone else writing</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">retry</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">setTimeout</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span>
+ <span class="nx">onFileChange</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
+ <span class="p">},</span> <span class="mi">1000</span><span class="p">);</span>
+ <span class="p">}</span>
<span class="k">return</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">});</span>
@@ -575,6 +582,8 @@
<span class="cm"> * (hostname).EXT</span>
<span class="cm"> * (deployment).EXT</span>
<span class="cm"> * (hostname)-(deployment).EXT</span>
+<span class="cm"> * local.EXT</span>
+<span class="cm"> * local-(deployment).EXT</span>
<span class="cm"> * runtime.json</span>
<span class="cm"> * &lt;/pre&gt;</span>
<span class="cm"> *</span>
@@ -627,7 +636,7 @@
<span class="kd">var</span> <span class="nx">deployment</span> <span class="o">=</span> <span class="nx">process</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">NODE_ENV</span> <span class="o">||</span> <span class="s1">&#39;development&#39;</span><span class="p">;</span>
<span class="c1">// Read each file in turn</span>
- <span class="kd">var</span> <span class="nx">baseNames</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;default&#39;</span><span class="p">,</span> <span class="nx">hostName</span><span class="p">,</span> <span class="nx">deployment</span><span class="p">,</span> <span class="nx">hostName</span> <span class="o">+</span> <span class="s1">&#39;-&#39;</span> <span class="o">+</span> <span class="nx">deployment</span><span class="p">];</span>
+ <span class="kd">var</span> <span class="nx">baseNames</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;default&#39;</span><span class="p">,</span> <span class="nx">hostName</span><span class="p">,</span> <span class="nx">deployment</span><span class="p">,</span> <span class="nx">hostName</span> <span class="o">+</span> <span class="s1">&#39;-&#39;</span> <span class="o">+</span> <span class="nx">deployment</span><span class="p">,</span> <span class="s1">&#39;local&#39;</span><span class="p">,</span> <span class="s1">&#39;local-&#39;</span> <span class="o">+</span> <span class="nx">deployment</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">extNames</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;js&#39;</span><span class="p">,</span> <span class="s1">&#39;json&#39;</span><span class="p">,</span> <span class="s1">&#39;coffee&#39;</span><span class="p">,</span> <span class="s1">&#39;yaml&#39;</span><span class="p">];</span>
<span class="nx">baseNames</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">baseName</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">extNames</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">extName</span><span class="p">)</span> <span class="p">{</span>
@@ -689,8 +698,15 @@
<span class="c1">// Make sure the runtime.json file exists. This is required for fs.watch().</span>
<span class="kd">var</span> <span class="nx">checkRuntimeJson</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">fullFilename</span> <span class="o">==</span> <span class="nx">runtimeJsonFilename</span><span class="p">)</span> <span class="p">{</span>
-<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Writing runtime json file&quot;</span><span class="p">);</span>
- <span class="nx">FileSystem</span><span class="p">.</span><span class="nx">writeFileSync</span><span class="p">(</span><span class="nx">runtimeJsonFilename</span><span class="p">,</span> <span class="s1">&#39;{}&#39;</span><span class="p">);</span>
+ <span class="k">try</span> <span class="p">{</span>
+ <span class="nx">FileSystem</span><span class="p">.</span><span class="nx">writeFileSync</span><span class="p">(</span><span class="nx">runtimeJsonFilename</span><span class="p">,</span> <span class="s1">&#39;{}&#39;</span><span class="p">);</span>
+ <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Cannot write runtime.json file &quot;</span> <span class="o">+</span> <span class="nx">e</span><span class="p">);</span>
+ <span class="c1">//if we cannot write file, clear watch function</span>
+ <span class="nx">t</span><span class="p">.</span><span class="nx">watchForConfigFileChanges</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="k">return</span><span class="p">;</span>
+ <span class="p">};</span>
+ <span class="p">}</span>
<span class="k">return</span> <span class="p">{};</span>
<span class="p">}</span>
<span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
@@ -719,12 +735,27 @@
<span class="c1">// Parse the file based on extension</span>
<span class="k">try</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">extension</span> <span class="o">==</span> <span class="s1">&#39;yaml&#39;</span><span class="p">)</span> <span class="p">{</span>
- <span class="c1">// Lazy loading</span>
- <span class="nx">Yaml</span> <span class="o">=</span> <span class="nx">Yaml</span> <span class="o">||</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;yaml&#39;</span><span class="p">);</span>
- <span class="c1">// The yaml library doesn&#39;t like strings that have newlines but don&#39;t</span>
- <span class="c1">// end in a newline: https://github.com/visionmedia/js-yaml/issues/issue/13</span>
- <span class="nx">fileContent</span> <span class="o">+=</span> <span class="s1">&#39;\n&#39;</span><span class="p">;</span>
- <span class="nx">configObject</span> <span class="o">=</span> <span class="nx">Yaml</span><span class="p">.</span><span class="nb">eval</span><span class="p">(</span><span class="nx">t</span><span class="p">.</span><span class="nx">_stripYamlComments</span><span class="p">(</span><span class="nx">fileContent</span><span class="p">));</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">Yaml</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">VisionmediaYaml</span><span class="p">)</span> <span class="p">{</span>
+ <span class="c1">// Lazy loading</span>
+ <span class="k">try</span> <span class="p">{</span>
+ <span class="c1">// Try to load the better js-yaml module</span>
+ <span class="nx">Yaml</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;js-yaml&#39;</span><span class="p">);</span>
+ <span class="p">}</span>
+ <span class="k">catch</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
+ <span class="c1">// If it doesn&#39;t exist, load the fallback visionmedia yaml module.</span>
+ <span class="nx">VisionmediaYaml</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;yaml&#39;</span><span class="p">);</span>
+ <span class="p">}</span>
+ <span class="p">}</span>
+
+ <span class="k">if</span> <span class="p">(</span><span class="nx">Yaml</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">configObject</span> <span class="o">=</span> <span class="nx">Yaml</span><span class="p">.</span><span class="nx">load</span><span class="p">(</span><span class="nx">t</span><span class="p">.</span><span class="nx">_stripYamlComments</span><span class="p">(</span><span class="nx">fileContent</span><span class="p">));</span>
+ <span class="p">}</span>
+ <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">VisionmediaYaml</span><span class="p">)</span> <span class="p">{</span>
+ <span class="c1">// The yaml library doesn&#39;t like strings that have newlines but don&#39;t</span>
+ <span class="c1">// end in a newline: https://github.com/visionmedia/js-yaml/issues/issue/13</span>
+ <span class="nx">fileContent</span> <span class="o">+=</span> <span class="s1">&#39;\n&#39;</span><span class="p">;</span>
+ <span class="nx">configObject</span> <span class="o">=</span> <span class="nx">VisionmediaYaml</span><span class="p">.</span><span class="nb">eval</span><span class="p">(</span><span class="nx">t</span><span class="p">.</span><span class="nx">_stripYamlComments</span><span class="p">(</span><span class="nx">fileContent</span><span class="p">));</span>
+ <span class="p">}</span>
<span class="p">}</span>
<span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">extension</span> <span class="o">==</span> <span class="s1">&#39;json&#39;</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// Allow comments in JSON files</span>
@@ -825,7 +856,7 @@
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">prop</span> <span class="k">in</span> <span class="nx">obj</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// Call recursively if an object or array</span>
- <span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">obj</span><span class="p">[</span><span class="nx">prop</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;object&#39;</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">obj</span><span class="p">[</span><span class="nx">prop</span><span class="p">]</span> <span class="o">&amp;&amp;</span> <span class="k">typeof</span> <span class="nx">obj</span><span class="p">[</span><span class="nx">prop</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;object&#39;</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">copy</span><span class="p">[</span><span class="nx">prop</span><span class="p">]</span> <span class="o">=</span> <span class="nx">t</span><span class="p">.</span><span class="nx">_cloneDeep</span><span class="p">(</span><span class="nx">obj</span><span class="p">[</span><span class="nx">prop</span><span class="p">],</span> <span class="nx">depth</span> <span class="o">-</span> <span class="mi">1</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">else</span> <span class="p">{</span>
@@ -879,7 +910,7 @@
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">prop</span> <span class="k">in</span> <span class="nx">object1</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// Call recursively if an object or array</span>
- <span class="k">if</span> <span class="p">(</span><span class="k">typeof</span><span class="p">(</span><span class="nx">object1</span><span class="p">[</span><span class="nx">prop</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;object&#39;</span><span class="p">))</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">object1</span><span class="p">[</span><span class="nx">prop</span><span class="p">]</span> <span class="o">&amp;&amp;</span> <span class="k">typeof</span><span class="p">(</span><span class="nx">object1</span><span class="p">[</span><span class="nx">prop</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;object&#39;</span><span class="p">))</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">t</span><span class="p">.</span><span class="nx">_equalsDeep</span><span class="p">(</span><span class="nx">object1</span><span class="p">[</span><span class="nx">prop</span><span class="p">],</span> <span class="nx">object2</span><span class="p">[</span><span class="nx">prop</span><span class="p">],</span> <span class="nx">depth</span> <span class="o">-</span> <span class="mi">1</span><span class="p">))</span> <span class="p">{</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">}</span>
@@ -929,7 +960,7 @@
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">parm</span> <span class="k">in</span> <span class="nx">object2</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">value1</span> <span class="o">=</span> <span class="nx">object1</span><span class="p">[</span><span class="nx">parm</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">value2</span> <span class="o">=</span> <span class="nx">object2</span><span class="p">[</span><span class="nx">parm</span><span class="p">];</span>
- <span class="k">if</span> <span class="p">(</span><span class="k">typeof</span><span class="p">(</span><span class="nx">value2</span><span class="p">)</span> <span class="o">==</span> <span class="s1">&#39;object&#39;</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">value2</span> <span class="o">&amp;&amp;</span> <span class="k">typeof</span><span class="p">(</span><span class="nx">value2</span><span class="p">)</span> <span class="o">==</span> <span class="s1">&#39;object&#39;</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="p">(</span><span class="nx">t</span><span class="p">.</span><span class="nx">_equalsDeep</span><span class="p">(</span><span class="nx">value1</span><span class="p">,</span> <span class="nx">value2</span><span class="p">)))</span> <span class="p">{</span>
<span class="nx">diff</span><span class="p">[</span><span class="nx">parm</span><span class="p">]</span> <span class="o">=</span> <span class="nx">t</span><span class="p">.</span><span class="nx">_diffDeep</span><span class="p">(</span><span class="nx">value1</span><span class="p">,</span> <span class="nx">value2</span><span class="p">,</span> <span class="nx">depth</span> <span class="o">-</span> <span class="mi">1</span><span class="p">);</span>
<span class="p">}</span>
@@ -1091,7 +1122,7 @@
<span class="cm"> * @return {boolean} TRUE if the arg is an object, FALSE if not</span>
<span class="cm"> */</span>
<span class="nx">Config</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_isObject</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">return</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">obj</span> <span class="o">==</span> <span class="s1">&#39;object&#39;</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="p">(</span><span class="nb">Array</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">obj</span><span class="p">));</span>
+ <span class="k">return</span> <span class="p">(</span><span class="nx">obj</span> <span class="o">!==</span> <span class="kc">null</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">obj</span> <span class="o">==</span> <span class="s1">&#39;object&#39;</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="p">(</span><span class="nb">Array</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">obj</span><span class="p">));</span>
<span class="p">};</span>
<span class="c1">// Assure the configuration object is a singleton.</span>
@@ -1143,7 +1174,7 @@
<div id="ft">
<hr />
Released on <a href="https://github.com/lorenwest/node-config">github</a> under the <a href="https://github.com/lorenwest/node-config/blob/master/LICENSE">Apache License 2.0</a>
-<span class="subtitle">version 0.4.13</span>
+<span class="subtitle">version 0.4.14</span>
</div>
</div>
<script type="text/javascript">
View
10 doc/default.js.html
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>test default.js </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1335400935.57" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1335400935.57" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1338535530.96" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1338535530.96" />
- <script type="text/javascript" src="assets/api-js?stamp=1335400935.57"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1335400935.57"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1338535530.96"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1338535530.96"></script>
</head>
<body id="node-monitor">
@@ -98,7 +98,7 @@
<div id="ft">
<hr />
Released on <a href="https://github.com/lorenwest/node-config">github</a> under the <a href="https://github.com/lorenwest/node-config/blob/master/LICENSE">Apache License 2.0</a>
-<span class="subtitle">version 0.4.13</span>
+<span class="subtitle">version 0.4.14</span>
</div>
</div>
<script type="text/javascript">
View
10 doc/index.html
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title> </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1335400935.63" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1335400935.63" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1338535531.01" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1338535531.01" />
- <script type="text/javascript" src="assets/api-js?stamp=1335400935.63"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1335400935.63"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1338535531.01"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1338535531.01"></script>
</head>
<body id="node-monitor">
@@ -288,7 +288,7 @@
<div id="ft">
<hr />
Released on <a href="https://github.com/lorenwest/node-config">github</a> under the <a href="https://github.com/lorenwest/node-config/blob/master/LICENSE">Apache License 2.0</a>
-<span class="subtitle">version 0.4.13</span>
+<span class="subtitle">version 0.4.14</span>
</div>
</div>
<script type="text/javascript">
View
10 doc/module_config.html
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>config </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1335400935.6" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1335400935.6" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1338535530.99" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1338535530.99" />
- <script type="text/javascript" src="assets/api-js?stamp=1335400935.6"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1335400935.6"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1338535530.99"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1338535530.99"></script>
</head>
<body id="node-monitor">
@@ -141,7 +141,7 @@
<div id="ft">
<hr />
Released on <a href="https://github.com/lorenwest/node-config">github</a> under the <a href="https://github.com/lorenwest/node-config/blob/master/LICENSE">Apache License 2.0</a>
-<span class="subtitle">version 0.4.13</span>
+<span class="subtitle">version 0.4.14</span>
</div>
</div>
<script type="text/javascript">
View
10 doc/module_test.html
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>test </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1335400935.57" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1335400935.57" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1338535530.96" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1338535530.96" />
- <script type="text/javascript" src="assets/api-js?stamp=1335400935.57"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1335400935.57"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1338535530.96"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1338535530.96"></script>
</head>
<body id="node-monitor">
@@ -113,7 +113,7 @@
<div id="ft">
<hr />
Released on <a href="https://github.com/lorenwest/node-config">github</a> under the <a href="https://github.com/lorenwest/node-config/blob/master/LICENSE">Apache License 2.0</a>
-<span class="subtitle">version 0.4.13</span>
+<span class="subtitle">version 0.4.14</span>
</div>
</div>
<script type="text/javascript">
View
2 doc/raw.json
@@ -1 +1 @@
-{"majorversion": 3, "classmap": {"ConfigTest": {"name": "ConfigTest", "namespace": "", "module": "test", "guessedname": "ConfigTest", "file": "2-config-test.js", "guessedtype": "property", "shortname": "ConfigTest", "description": "<p>Unit tests for the node-config library. To run type:</p>\n<pre>npm test config</pre>"}, "Config": {"name": "Config", "namespace": "", "module": "config", "methods": {"watchForConfigFileChanges": {"params": [{"type": "Integer", "name": "interval", "description": " - Polling interval in milliseconds. Defaults to 2500."}], "description": "Change the runtime.json file watching polling interval.\n<p>\nNode-config automatically monitors and apply changes made to the\nconfig/runtime.json file. This paradigm allows for manual changes to running\napplication servers, and for multi-node application servers to keep in sync.\n</p>\n<p>\nThis method allows you to change the polling interval from the default\ninterval (2.5 seconds), or to turn file watching off. On Linux systems with\ninotify, and in node.js versions 0.6 and above, this interval is ignored.\n</p>", "guessedname": "watchForConfigFileChanges", "guessedtype": "function"}, "_attachProtoDeep": {"return": {"type": "", "description": "toObject"}, "description": "Attach the Config class prototype to all config objects recursively.\n<p>\nThis allows you to do anything with CONFIG sub-objects as you can do with\nthe top-level CONFIG object. It's so you can do this:\n</p>\n<pre>\nvar CUST_CONFIG = require('config').Customer;\nCUST_CONFIG.watch(...)\n</pre>", "protected": "", "params": [{"type": "", "name": "toObject", "description": ""}, {"type": "", "name": "depth", "description": ""}], "guessedname": "_attachProtoDeep", "guessedtype": "function"}, "_persistConfigsOnChange": {"protected": "", "params": [{"type": "object", "name": "object", "description": " - The config object to watch"}], "description": "<p>\nWatch the specified object for a change in properties, and persist changes\nto runtime.json when a change is detected.\n</p>", "guessedname": "_persistConfigsOnChange", "guessedtype": "function"}, "setModuleDefaults": {"return": {"type": "object", "description": "moduleConfig - The module level configuration object."}, "params": [{"type": "string", "name": "moduleName", "description": " - Name of your module."}, {"type": "object", "name": "defaultProperties", "description": " - The default module configuration."}], "description": "<p>\nSet default configurations for a node.js module.\n</p>\n<p>\nThis allows module developers to attach their configurations onto the\ndefault configuration object so they can be configured by the consumers\nof the module.\n</p>\n<p>Using the function within your module:</p>\n<pre>\nvar CONFIG = require(\"config\");\nCONFIG.setModuleDefaults(\"MyModule\", {\n&nbsp;&nbsp;templateName: \"t-50\",\n&nbsp;&nbsp;colorScheme: \"green\"\n});\n<br>\n// Template name may be overridden by application config files\nconsole.log(\"Template: \" + CONFIG.MyModule.templateName);\n</pre>\n<p>\nThe above example results in a \"MyModule\" element of the configuration\nobject, containing an object with the specified default values.\n</p>", "guessedname": "setModuleDefaults", "guessedtype": "function"}, "watch": {"return": {"type": "object", "description": "object - The original object is returned - for chaining."}, "params": [{"type": "object", "name": "object", "description": " - The object to watch."}, {"type": "string", "name": "property", "description": " - The property name to watch. Watch all object properties if null."}, {"type": "function(object, propertyName, priorValue, newValue)", "name": "handler", "description": " - Handler called when a property change is detected.\nThe handler is run along with other handlers registered for notification.\nIf your handler changes the value of the property, that change is applied after all handlers have finished processing the current change.\nThen all handlers (including this one) will be called again with the newly changed value."}, {"type": "integer", "name": "depth", "description": " (optional) - If watching all object properties or if the specified property is an object, this specifies the depth of the object graph to watch for changes. Default 6."}], "description": "<p>Monitor a configuration value for runtime changes.</p>\n<p>\nConfiguration values can be changed at runtime by the application or by a\nmanual change to the config/runtime.json file.\nThis method lets you specify a function to run when a configuration\nvalue changes.\n</p>\n<p><i>\nThis was built for monitoring changes to configuration values,\nbut it can be used for watching changes to <u>any</u> javascript object.\n</i></p>\n<p>Example:</p>\n<pre>\nvar CONFIG = require('config').customer;\n...\n// Watch for any changes to the customer configuration\nCONFIG.watch(CONFIG, null, function(object, propertyName, priorValue, newValue) {\n&nbsp;console.log(\"Customer configuration \" + propertyName + \" changed from \" + priorValue + \" to \" + newValue);\n});\n</pre>", "guessedname": "watch", "guessedtype": "function"}, "_stripComments": {"return": {"type": "string", "description": "The string with comments stripped."}, "description": "Strip all Javascript type comments from the string.\nThe string is usually a file loaded from the O/S, containing\nnewlines and javascript type comments.\nThanks to James Padolsey, and all who conributed to this implementation.\nhttp://james.padolsey.com/javascript/javascript-comment-removal-revisted/", "protected": "", "params": [{"type": "string", "name": "fileString", "description": " The string to strip comments from"}], "guessedname": "_stripComments", "guessedtype": "function"}, "makeHidden": {"return": {"type": "object", "description": "object - The original object is returned - for chaining."}, "params": [{"type": "object", "name": "object", "description": " - The object to make a hidden property into."}, {"type": "string", "name": "property", "description": " - The name of the property to make hidden."}, {"type": "mixed", "name": "value", "description": " - (optional) Set the property value to this (otherwise leave alone)"}], "description": "<p>Make a configuration property hidden so it doesn't appear when enumerating\nelements of the object.</p>\n<p>\nThe property still exists and can be read from and written to, but it won't\nshow up in for ... in loops, Object.keys(), or JSON.stringify() type methods.\n</p>\n<p>\nIf the property already exists, it will be made hidden. Otherwise it will\nbe created as a hidden property with the specified value.\n</p>\n<p><i>\nThis method was built for hiding configuration values, but it can be applied\nto <u>any</u> javascript object.\n</i></p>\n<p>Example:</p>\n<pre>\nvar CONFIG = require('config');\n...\n// Hide the Amazon S3 credentials\nCONFIG.makeHidden(CONFIG.amazonS3, 'access_id');\nCONFIG.makeHidden(CONFIG.amazonS3, 'secret_key');\n</pre>", "guessedname": "makeHidden", "guessedtype": "function"}, "_equalsDeep": {"return": {"type": "boolean", "description": "True if both objects have equivalent contents"}, "description": "Return true if two objects have equal contents.", "protected": "", "params": [{"type": "object", "name": "object1", "description": " The object to compare from"}, {"type": "object", "name": "object2", "description": " The object to compare with"}, {"type": "integer", "name": "depth", "description": " An optional depth to prevent recursion. Default: 20."}], "guessedname": "_equalsDeep", "guessedtype": "function"}, "_stripYamlComments": {"return": {"type": "string", "description": "The string with comments stripped."}, "description": "Strip YAML comments from the string\nThe 2.0 yaml parser doesn't allow comment-only or blank lines. Strip them.", "protected": "", "params": [{"type": "string", "name": "fileString", "description": " The string to strip comments from"}], "guessedname": "_stripYamlComments", "guessedtype": "function"}, "makeImmutable": {"return": {"type": "object", "description": "object - The original object is returned - for chaining."}, "params": [{"type": "object", "name": "object", "description": " - The object to attach an immutable property into."}, {"type": "string", "name": "property", "description": " - The name of the property to make immutable."}, {"type": "mixed", "name": "value", "description": " - (optional) Set the property value to this (otherwise leave alone)"}], "description": "<p>Make a configuration property immutable (assuring it cannot be changed\nfrom the current value).</p>\n<p>\nThis operation cannot be un-done.\n</p>\n<p><i>\nThis method was built for disabling runtime changes to configuration values,\nbut it can be applied to <u>any</u> javascript object.\n</i></p>\n<p>Example:</p>\n<pre>\nvar CONFIG = require('config').customer;\n...\n// Obtain a DB connection using CONFIG parameters\ndatabase.open(CONFIG.db.name, CONFIG.db.port);\n...\n// Don't allow database changes after connect\nCONFIG.makeImmutable(CONFIG.db, 'name');\nCONFIG.makeImmutable(CONFIG.db, 'port');\n</pre>", "guessedname": "makeImmutable", "guessedtype": "function"}, "_cloneDeep": {"return": {"type": "object", "description": "A new object with the elements copied from the copyFrom object"}, "description": "Return a deep copy of the specified object.\nThis returns a new object with all elements copied from the specified\nobject. Deep copies are made of objects and arrays so you can do anything\nwith the returned object without affecting the input object.", "protected": "", "params": [{"type": "object", "name": "copyFrom", "description": " The original object to copy from"}, {"type": "integer", "name": "depth", "description": " An optional depth to prevent recursion. Default: 20."}], "guessedname": "_cloneDeep", "guessedtype": "function"}, "_loadFileConfigs": {"protected": "", "return": {"type": "this", "description": "The configuration object"}, "description": "Load the individual file configurations.\n<p>\nThis method builds a map of filename to the configuration object defined\nby the file. The search order is:\n</p>\n<pre>\ndefault.EXT\n(hostname).EXT\n(deployment).EXT\n(hostname)-(deployment).EXT\nruntime.json\n</pre>\n<p>\nEXT can be yaml, coffee, json, or js signifying the file type.\nyaml is in YAML format, coffee is a coffee-script,\njson is in strict JSON format, and js is a javascript executable file that is\nrequire()'d with module.exports being the config object.\n</p>\n<p>\n(hostname) is the $HOST environment variable if set, otherwise the\nhostname found from require('os').hostname()\n</p>\n<p>\n(deployment) is the deployment type, found in the $NODE_ENV environment\nvariable. Defaults to 'development'.\n</p>\n<p>\nThe runtime.json file contains configuration changes made at runtime either\nmanually, or by the application setting a configuration value.\n</p>", "guessedname": "_loadFileConfigs", "guessedtype": "function"}, "constructor": {"return": {"type": "object", "description": "CONFIG - The top level configuration object"}, "description": "<p>Get the configuration object.</p>\n<p>\nThe configuration object is a shared singleton object within the applicaiton,\nattained by calling require('config').\n</p>\n<p>\nUsually you'll specify a CONFIG variable at the top of your .js file\nfor file/module scope. If you want the root of the object, you can do this:\n</p>\n<pre>\nvar CONFIG = require('config');\n</pre>\n<p>\nSometimes you only care about a specific sub-object within the CONFIG\nobject. In that case you could do this at the top of your file:\n</p>\n<pre>\nvar CONFIG = require('config').customer;\nor\nvar CUSTOMER_CONFIG = require('config').customer;\n</pre>\n<script type=\"text/javascript\">\ndocument.getElementById(\"showProtected\").style.display = \"block\";\n</script>", "guessedname": "Config", "guessedtype": "function"}, "_diffDeep": {"return": {"type": "object", "description": "A differential object, which if extended onto object1 would\nresult in object2."}, "description": "Returns an object containing all elements that differ between two objects.\n<p>\nThis method was designed to be used to create the runtime.json file\ncontents, but can be used to get the diffs between any two Javascript objects.\n</p>\n<p>\nIt works best when object2 originated by deep copying object1, then\nchanges were made to object2, and you want an object that would give you\nthe changes made to object1 which resulted in object2.\n</p>", "protected": "", "params": [{"type": "object", "name": "object1", "description": " The base object to compare to"}, {"type": "object", "name": "object2", "description": " The object to compare with"}, {"type": "integer", "name": "depth", "description": " An optional depth to prevent recursion. Default: 20."}], "guessedname": "_diffDeep", "guessedtype": "function"}, "_isObject": {"return": {"type": "boolean", "description": "TRUE if the arg is an object, FALSE if not"}, "description": "Is the specified argument a regular javascript object?\nThe argument is an object if it's a JS object, but not an array.", "protected": "", "params": [{"type": "MIXED", "name": "arg", "description": " An argument of any type."}], "guessedname": "_isObject", "guessedtype": "function"}, "_parseFile": {"return": {"type": "configObject", "description": "The configuration object parsed from the file"}, "description": "Parse and return the specified configuration file.\nIf the file exists in the application config directory, it will\nparse and return it as a JavaScript object.\nThe file extension determines the parser to use.\n.js = File to run that has a module.exports containing the config object\n.json = File is parsed using JSON.parse()\n.coffee = File to run that has a module.exports with coffee-script containing the config object\n.yaml = Parsed with a YAML parser\nIf the file doesn't exist, a null will be returned. If the file can't be\nparsed, an exception will be thrown.\nThis method performs synchronous file operations, and should not be called\nafter synchronous module loading.", "protected": "", "params": [{"type": "string", "name": "fullFilename", "description": " The full file path and name"}], "guessedname": "_parseFile", "guessedtype": "function"}, "_extendDeep": {"return": {"type": "object", "description": "The altered mergeInto object is returned"}, "description": "Extend an object, and any object it contains.\nThis does not replace deep objects, but dives into them\nreplacing individual elements instead.", "protected": "", "params": [{"type": "object", "name": "mergeInto", "description": " The object to merge into"}, {"type": "object...", "name": "mergeFrom...", "description": " - Any number of objects to merge from"}, {"type": "integer", "name": "depth", "description": " An optional depth to prevent recursion. Default: 20."}], "guessedname": "_extendDeep", "guessedtype": "function"}}, "file": "config.js", "shortname": "Config", "description": "<p>Runtime Application Configurations</p>\n<p>\nThe config module exports a singleton object representing all runtime\nconfigurations for this application deployment.\n</p>\n<p>\nApplication configurations are stored in files within the config directory\nof your application. The default configuration file is loaded, followed\nby files specific to the deployment type (development, testing, staging,\nproduction, etc.).\n</p>\n<p>\nFor example, with the following config/default.yaml file:\n</p>\n<pre>\n...\ncustomer:\n&nbsp;&nbsp;initialCredit: 500\n&nbsp;&nbsp;db:\n&nbsp;&nbsp;&nbsp;&nbsp;name: customer\n&nbsp;&nbsp;&nbsp;&nbsp;port: 5984\n...\n</pre>\n<p>\nThe following code loads the customer section into the CONFIG variable:\n<p>\n<pre>\nvar CONFIG = require('config').customer;\n...\nnewCustomer.creditLimit = CONFIG.initialCredit;\ndatabase.open(CONFIG.db.name, CONFIG.db.port);\n...\n</pre>"}, "ProtectedTest": {"name": "ProtectedTest", "namespace": "", "module": "test", "guessedname": "PrivateTest", "file": "1-protected-test.js", "guessedtype": "property", "shortname": "ProtectedTest", "description": "<p>Tests for underlying node-config utilities. To run type:</p>\n<pre>npm test config</pre>"}}, "version": "0.4.13", "modules": {"test": {"description": "<p>Unit tests</p>", "submodules": [], "classlist": ["ProtectedTest", "ConfigTest"], "filelist": ["1-protected-test.js", "2-config-test.js", "default.js"], "subdata": {}, "name": "test"}, "config": {"description": "<p>Runtime Application Configurations</p>\n<p>\nThe config module exports a singleton object representing all runtime\nconfigurations for this application deployment.\n</p>\n<p>\nApplication configurations are stored in files within the config directory\nof your application. The default configuration file is loaded, followed\nby files specific to the deployment type (development, testing, staging,\nproduction, etc.).\n</p>\n<p>\nFor example, with the following config/default.yaml file:\n</p>\n<pre>\n...\ncustomer:\n&nbsp;&nbsp;initialCredit: 500\n&nbsp;&nbsp;db:\n&nbsp;&nbsp;&nbsp;&nbsp;name: customer\n&nbsp;&nbsp;&nbsp;&nbsp;port: 5984\n...\n</pre>\n<p>\nThe following code loads the customer section into the CONFIG variable:\n<p>\n<pre>\nvar CONFIG = require('config').customer;\n...\nnewCustomer.creditLimit = CONFIG.initialCredit;\ndatabase.open(CONFIG.db.name, CONFIG.db.port);\n...\n</pre>", "submodules": [], "classlist": ["Config"], "filelist": ["config.js"], "subdata": {}, "name": "config"}}, "filemap": {"default.js": {"classlist": [], "name": "default.js", "module": "test"}, "2-config-test.js": {"classlist": ["ConfigTest"], "name": "2-config-test.js", "module": "test"}, "config.js": {"classlist": ["Config"], "name": "config.js", "module": "config"}, "1-protected-test.js": {"classlist": ["ProtectedTest"], "name": "1-protected-test.js", "module": "test"}}}
+{"majorversion": 3, "classmap": {"ConfigTest": {"name": "ConfigTest", "namespace": "", "module": "test", "guessedname": "ConfigTest", "file": "2-config-test.js", "guessedtype": "property", "shortname": "ConfigTest", "description": "<p>Unit tests for the node-config library. To run type:</p>\n<pre>npm test config</pre>"}, "Config": {"name": "Config", "namespace": "", "module": "config", "methods": {"watchForConfigFileChanges": {"params": [{"type": "Integer", "name": "interval", "description": " - Polling interval in milliseconds. Defaults to 2500."}], "description": "Change the runtime.json file watching polling interval.\n<p>\nNode-config automatically monitors and apply changes made to the\nconfig/runtime.json file. This paradigm allows for manual changes to running\napplication servers, and for multi-node application servers to keep in sync.\n</p>\n<p>\nThis method allows you to change the polling interval from the default\ninterval (2.5 seconds), or to turn file watching off. On Linux systems with\ninotify, and in node.js versions 0.6 and above, this interval is ignored.\n</p>", "guessedname": "watchForConfigFileChanges", "guessedtype": "function"}, "_attachProtoDeep": {"return": {"type": "", "description": "toObject"}, "description": "Attach the Config class prototype to all config objects recursively.\n<p>\nThis allows you to do anything with CONFIG sub-objects as you can do with\nthe top-level CONFIG object. It's so you can do this:\n</p>\n<pre>\nvar CUST_CONFIG = require('config').Customer;\nCUST_CONFIG.watch(...)\n</pre>", "protected": "", "params": [{"type": "", "name": "toObject", "description": ""}, {"type": "", "name": "depth", "description": ""}], "guessedname": "_attachProtoDeep", "guessedtype": "function"}, "_persistConfigsOnChange": {"protected": "", "params": [{"type": "object", "name": "object", "description": " - The config object to watch"}], "description": "<p>\nWatch the specified object for a change in properties, and persist changes\nto runtime.json when a change is detected.\n</p>", "guessedname": "_persistConfigsOnChange", "guessedtype": "function"}, "setModuleDefaults": {"return": {"type": "object", "description": "moduleConfig - The module level configuration object."}, "params": [{"type": "string", "name": "moduleName", "description": " - Name of your module."}, {"type": "object", "name": "defaultProperties", "description": " - The default module configuration."}], "description": "<p>\nSet default configurations for a node.js module.\n</p>\n<p>\nThis allows module developers to attach their configurations onto the\ndefault configuration object so they can be configured by the consumers\nof the module.\n</p>\n<p>Using the function within your module:</p>\n<pre>\nvar CONFIG = require(\"config\");\nCONFIG.setModuleDefaults(\"MyModule\", {\n&nbsp;&nbsp;templateName: \"t-50\",\n&nbsp;&nbsp;colorScheme: \"green\"\n});\n<br>\n// Template name may be overridden by application config files\nconsole.log(\"Template: \" + CONFIG.MyModule.templateName);\n</pre>\n<p>\nThe above example results in a \"MyModule\" element of the configuration\nobject, containing an object with the specified default values.\n</p>", "guessedname": "setModuleDefaults", "guessedtype": "function"}, "watch": {"return": {"type": "object", "description": "object - The original object is returned - for chaining."}, "params": [{"type": "object", "name": "object", "description": " - The object to watch."}, {"type": "string", "name": "property", "description": " - The property name to watch. Watch all object properties if null."}, {"type": "function(object, propertyName, priorValue, newValue)", "name": "handler", "description": " - Handler called when a property change is detected.\nThe handler is run along with other handlers registered for notification.\nIf your handler changes the value of the property, that change is applied after all handlers have finished processing the current change.\nThen all handlers (including this one) will be called again with the newly changed value."}, {"type": "integer", "name": "depth", "description": " (optional) - If watching all object properties or if the specified property is an object, this specifies the depth of the object graph to watch for changes. Default 6."}], "description": "<p>Monitor a configuration value for runtime changes.</p>\n<p>\nConfiguration values can be changed at runtime by the application or by a\nmanual change to the config/runtime.json file.\nThis method lets you specify a function to run when a configuration\nvalue changes.\n</p>\n<p><i>\nThis was built for monitoring changes to configuration values,\nbut it can be used for watching changes to <u>any</u> javascript object.\n</i></p>\n<p>Example:</p>\n<pre>\nvar CONFIG = require('config').customer;\n...\n// Watch for any changes to the customer configuration\nCONFIG.watch(CONFIG, null, function(object, propertyName, priorValue, newValue) {\n&nbsp;console.log(\"Customer configuration \" + propertyName + \" changed from \" + priorValue + \" to \" + newValue);\n});\n</pre>", "guessedname": "watch", "guessedtype": "function"}, "_stripComments": {"return": {"type": "string", "description": "The string with comments stripped."}, "description": "Strip all Javascript type comments from the string.\nThe string is usually a file loaded from the O/S, containing\nnewlines and javascript type comments.\nThanks to James Padolsey, and all who conributed to this implementation.\nhttp://james.padolsey.com/javascript/javascript-comment-removal-revisted/", "protected": "", "params": [{"type": "string", "name": "fileString", "description": " The string to strip comments from"}], "guessedname": "_stripComments", "guessedtype": "function"}, "makeHidden": {"return": {"type": "object", "description": "object - The original object is returned - for chaining."}, "params": [{"type": "object", "name": "object", "description": " - The object to make a hidden property into."}, {"type": "string", "name": "property", "description": " - The name of the property to make hidden."}, {"type": "mixed", "name": "value", "description": " - (optional) Set the property value to this (otherwise leave alone)"}], "description": "<p>Make a configuration property hidden so it doesn't appear when enumerating\nelements of the object.</p>\n<p>\nThe property still exists and can be read from and written to, but it won't\nshow up in for ... in loops, Object.keys(), or JSON.stringify() type methods.\n</p>\n<p>\nIf the property already exists, it will be made hidden. Otherwise it will\nbe created as a hidden property with the specified value.\n</p>\n<p><i>\nThis method was built for hiding configuration values, but it can be applied\nto <u>any</u> javascript object.\n</i></p>\n<p>Example:</p>\n<pre>\nvar CONFIG = require('config');\n...\n// Hide the Amazon S3 credentials\nCONFIG.makeHidden(CONFIG.amazonS3, 'access_id');\nCONFIG.makeHidden(CONFIG.amazonS3, 'secret_key');\n</pre>", "guessedname": "makeHidden", "guessedtype": "function"}, "_equalsDeep": {"return": {"type": "boolean", "description": "True if both objects have equivalent contents"}, "description": "Return true if two objects have equal contents.", "protected": "", "params": [{"type": "object", "name": "object1", "description": " The object to compare from"}, {"type": "object", "name": "object2", "description": " The object to compare with"}, {"type": "integer", "name": "depth", "description": " An optional depth to prevent recursion. Default: 20."}], "guessedname": "_equalsDeep", "guessedtype": "function"}, "_stripYamlComments": {"return": {"type": "string", "description": "The string with comments stripped."}, "description": "Strip YAML comments from the string\nThe 2.0 yaml parser doesn't allow comment-only or blank lines. Strip them.", "protected": "", "params": [{"type": "string", "name": "fileString", "description": " The string to strip comments from"}], "guessedname": "_stripYamlComments", "guessedtype": "function"}, "makeImmutable": {"return": {"type": "object", "description": "object - The original object is returned - for chaining."}, "params": [{"type": "object", "name": "object", "description": " - The object to attach an immutable property into."}, {"type": "string", "name": "property", "description": " - The name of the property to make immutable."}, {"type": "mixed", "name": "value", "description": " - (optional) Set the property value to this (otherwise leave alone)"}], "description": "<p>Make a configuration property immutable (assuring it cannot be changed\nfrom the current value).</p>\n<p>\nThis operation cannot be un-done.\n</p>\n<p><i>\nThis method was built for disabling runtime changes to configuration values,\nbut it can be applied to <u>any</u> javascript object.\n</i></p>\n<p>Example:</p>\n<pre>\nvar CONFIG = require('config').customer;\n...\n// Obtain a DB connection using CONFIG parameters\ndatabase.open(CONFIG.db.name, CONFIG.db.port);\n...\n// Don't allow database changes after connect\nCONFIG.makeImmutable(CONFIG.db, 'name');\nCONFIG.makeImmutable(CONFIG.db, 'port');\n</pre>", "guessedname": "makeImmutable", "guessedtype": "function"}, "_cloneDeep": {"return": {"type": "object", "description": "A new object with the elements copied from the copyFrom object"}, "description": "Return a deep copy of the specified object.\nThis returns a new object with all elements copied from the specified\nobject. Deep copies are made of objects and arrays so you can do anything\nwith the returned object without affecting the input object.", "protected": "", "params": [{"type": "object", "name": "copyFrom", "description": " The original object to copy from"}, {"type": "integer", "name": "depth", "description": " An optional depth to prevent recursion. Default: 20."}], "guessedname": "_cloneDeep", "guessedtype": "function"}, "_loadFileConfigs": {"protected": "", "return": {"type": "this", "description": "The configuration object"}, "description": "Load the individual file configurations.\n<p>\nThis method builds a map of filename to the configuration object defined\nby the file. The search order is:\n</p>\n<pre>\ndefault.EXT\n(hostname).EXT\n(deployment).EXT\n(hostname)-(deployment).EXT\nlocal.EXT\nlocal-(deployment).EXT\nruntime.json\n</pre>\n<p>\nEXT can be yaml, coffee, json, or js signifying the file type.\nyaml is in YAML format, coffee is a coffee-script,\njson is in strict JSON format, and js is a javascript executable file that is\nrequire()'d with module.exports being the config object.\n</p>\n<p>\n(hostname) is the $HOST environment variable if set, otherwise the\nhostname found from require('os').hostname()\n</p>\n<p>\n(deployment) is the deployment type, found in the $NODE_ENV environment\nvariable. Defaults to 'development'.\n</p>\n<p>\nThe runtime.json file contains configuration changes made at runtime either\nmanually, or by the application setting a configuration value.\n</p>", "guessedname": "_loadFileConfigs", "guessedtype": "function"}, "constructor": {"return": {"type": "object", "description": "CONFIG - The top level configuration object"}, "description": "<p>Get the configuration object.</p>\n<p>\nThe configuration object is a shared singleton object within the applicaiton,\nattained by calling require('config').\n</p>\n<p>\nUsually you'll specify a CONFIG variable at the top of your .js file\nfor file/module scope. If you want the root of the object, you can do this:\n</p>\n<pre>\nvar CONFIG = require('config');\n</pre>\n<p>\nSometimes you only care about a specific sub-object within the CONFIG\nobject. In that case you could do this at the top of your file:\n</p>\n<pre>\nvar CONFIG = require('config').customer;\nor\nvar CUSTOMER_CONFIG = require('config').customer;\n</pre>\n<script type=\"text/javascript\">\ndocument.getElementById(\"showProtected\").style.display = \"block\";\n</script>", "guessedname": "Config", "guessedtype": "function"}, "_diffDeep": {"return": {"type": "object", "description": "A differential object, which if extended onto object1 would\nresult in object2."}, "description": "Returns an object containing all elements that differ between two objects.\n<p>\nThis method was designed to be used to create the runtime.json file\ncontents, but can be used to get the diffs between any two Javascript objects.\n</p>\n<p>\nIt works best when object2 originated by deep copying object1, then\nchanges were made to object2, and you want an object that would give you\nthe changes made to object1 which resulted in object2.\n</p>", "protected": "", "params": [{"type": "object", "name": "object1", "description": " The base object to compare to"}, {"type": "object", "name": "object2", "description": " The object to compare with"}, {"type": "integer", "name": "depth", "description": " An optional depth to prevent recursion. Default: 20."}], "guessedname": "_diffDeep", "guessedtype": "function"}, "_isObject": {"return": {"type": "boolean", "description": "TRUE if the arg is an object, FALSE if not"}, "description": "Is the specified argument a regular javascript object?\nThe argument is an object if it's a JS object, but not an array.", "protected": "", "params": [{"type": "MIXED", "name": "arg", "description": " An argument of any type."}], "guessedname": "_isObject", "guessedtype": "function"}, "_parseFile": {"return": {"type": "configObject", "description": "The configuration object parsed from the file"}, "description": "Parse and return the specified configuration file.\nIf the file exists in the application config directory, it will\nparse and return it as a JavaScript object.\nThe file extension determines the parser to use.\n.js = File to run that has a module.exports containing the config object\n.json = File is parsed using JSON.parse()\n.coffee = File to run that has a module.exports with coffee-script containing the config object\n.yaml = Parsed with a YAML parser\nIf the file doesn't exist, a null will be returned. If the file can't be\nparsed, an exception will be thrown.\nThis method performs synchronous file operations, and should not be called\nafter synchronous module loading.", "protected": "", "params": [{"type": "string", "name": "fullFilename", "description": " The full file path and name"}], "guessedname": "_parseFile", "guessedtype": "function"}, "_extendDeep": {"return": {"type": "object", "description": "The altered mergeInto object is returned"}, "description": "Extend an object, and any object it contains.\nThis does not replace deep objects, but dives into them\nreplacing individual elements instead.", "protected": "", "params": [{"type": "object", "name": "mergeInto", "description": " The object to merge into"}, {"type": "object...", "name": "mergeFrom...", "description": " - Any number of objects to merge from"}, {"type": "integer", "name": "depth", "description": " An optional depth to prevent recursion. Default: 20."}], "guessedname": "_extendDeep", "guessedtype": "function"}}, "file": "config.js", "shortname": "Config", "description": "<p>Runtime Application Configurations</p>\n<p>\nThe config module exports a singleton object representing all runtime\nconfigurations for this application deployment.\n</p>\n<p>\nApplication configurations are stored in files within the config directory\nof your application. The default configuration file is loaded, followed\nby files specific to the deployment type (development, testing, staging,\nproduction, etc.).\n</p>\n<p>\nFor example, with the following config/default.yaml file:\n</p>\n<pre>\n...\ncustomer:\n&nbsp;&nbsp;initialCredit: 500\n&nbsp;&nbsp;db:\n&nbsp;&nbsp;&nbsp;&nbsp;name: customer\n&nbsp;&nbsp;&nbsp;&nbsp;port: 5984\n...\n</pre>\n<p>\nThe following code loads the customer section into the CONFIG variable:\n<p>\n<pre>\nvar CONFIG = require('config').customer;\n...\nnewCustomer.creditLimit = CONFIG.initialCredit;\ndatabase.open(CONFIG.db.name, CONFIG.db.port);\n...\n</pre>"}, "ProtectedTest": {"name": "ProtectedTest", "namespace": "", "module": "test", "guessedname": "PrivateTest", "file": "1-protected-test.js", "guessedtype": "property", "shortname": "ProtectedTest", "description": "<p>Tests for underlying node-config utilities. To run type:</p>\n<pre>npm test config</pre>"}}, "version": "0.4.14", "modules": {"test": {"description": "<p>Unit tests</p>", "submodules": [], "classlist": ["ProtectedTest", "ConfigTest"], "filelist": ["1-protected-test.js", "2-config-test.js", "default.js"], "subdata": {}, "name": "test"}, "config": {"description": "<p>Runtime Application Configurations</p>\n<p>\nThe config module exports a singleton object representing all runtime\nconfigurations for this application deployment.\n</p>\n<p>\nApplication configurations are stored in files within the config directory\nof your application. The default configuration file is loaded, followed\nby files specific to the deployment type (development, testing, staging,\nproduction, etc.).\n</p>\n<p>\nFor example, with the following config/default.yaml file:\n</p>\n<pre>\n...\ncustomer:\n&nbsp;&nbsp;initialCredit: 500\n&nbsp;&nbsp;db:\n&nbsp;&nbsp;&nbsp;&nbsp;name: customer\n&nbsp;&nbsp;&nbsp;&nbsp;port: 5984\n...\n</pre>\n<p>\nThe following code loads the customer section into the CONFIG variable:\n<p>\n<pre>\nvar CONFIG = require('config').customer;\n...\nnewCustomer.creditLimit = CONFIG.initialCredit;\ndatabase.open(CONFIG.db.name, CONFIG.db.port);\n...\n</pre>", "submodules": [], "classlist": ["Config"], "filelist": ["config.js"], "subdata": {}, "name": "config"}}, "filemap": {"default.js": {"classlist": [], "name": "default.js", "module": "test"}, "2-config-test.js": {"classlist": ["ConfigTest"], "name": "2-config-test.js", "module": "test"}, "config.js": {"classlist": ["Config"], "name": "config.js", "module": "config"}, "1-protected-test.js": {"classlist": ["ProtectedTest"], "name": "1-protected-test.js", "module": "test"}}}
View
10 lib/config.js
@@ -230,7 +230,7 @@ Config.prototype.watch = function(object, property, handler, depth) {
o.__watchers[prop].push(handler);
// Recurs if this is an object...
- if (typeof(o[prop]) == 'object') {
+ if (o[prop] && typeof(o[prop]) == 'object') {
Config.prototype.watch(o[prop], null, handler, depth - 1);
}
@@ -808,7 +808,7 @@ Config.prototype._cloneDeep = function(obj, depth) {
for (var prop in obj) {
// Call recursively if an object or array
- if (typeof obj[prop] == 'object') {
+ if (obj[prop] && typeof obj[prop] == 'object') {
copy[prop] = t._cloneDeep(obj[prop], depth - 1);
}
else {
@@ -862,7 +862,7 @@ Config.prototype._equalsDeep = function(object1, object2, depth) {
for (var prop in object1) {
// Call recursively if an object or array
- if (typeof(object1[prop] == 'object')) {
+ if (object1[prop] && typeof(object1[prop] == 'object')) {
if (!t._equalsDeep(object1[prop], object2[prop], depth - 1)) {
return false;
}
@@ -912,7 +912,7 @@ Config.prototype._diffDeep = function(object1, object2, depth) {
for (var parm in object2) {
var value1 = object1[parm];
var value2 = object2[parm];
- if (typeof(value2) == 'object') {
+ if (value2 && typeof(value2) == 'object') {
if (!(t._equalsDeep(value1, value2))) {
diff[parm] = t._diffDeep(value1, value2, depth - 1);
}
@@ -1074,7 +1074,7 @@ Config.prototype._stripComments = function(fileStr) {
* @return {boolean} TRUE if the arg is an object, FALSE if not
*/
Config.prototype._isObject = function(obj) {
- return (typeof obj == 'object') && !(Array.isArray(obj));
+ return (obj !== null) && (typeof obj == 'object') && !(Array.isArray(obj));
};
// Assure the configuration object is a singleton.
View
2 package.json
@@ -1,6 +1,6 @@
{
"name": "config",
- "version": "0.4.13",
+ "version": "0.4.14",
"main": "./lib/config.js",
"description": "Configuration control for production node deployments",
"author": "Loren West <open_source@lorenwest.com>",
View
2 test/1-protected-test.js
@@ -40,6 +40,8 @@ exports.PrivateTest = vows.describe('Protected (hackable) utilities test').addBa
assert.isFalse(CONFIG._isObject(45));
assert.isFalse(CONFIG._isObject([2, 3]));
assert.isFalse(CONFIG._isObject(["a", "b"]));
+ assert.isFalse(CONFIG._isObject(null));
+ assert.isFalse(CONFIG._isObject(undefined));
}
},

0 comments on commit 44c1b47

Please sign in to comment.