First version
[src/app-framework-demo.git] / afm-client / app / etc / _Config.js
1 /* 
2  * Copyright 2014 Fulup Ar Foll
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 var fs = require('fs');
18
19 function Config () {
20    'use strict';
21    var values=[];
22    var extention='-l4a.js';
23    var conf;
24
25    // Configs file path last one supersead first one.
26    var files= [__dirname + "/AppDefaults.js", "/etc/default/noderc"+ extention, process.env.NODERC, process.env.HOME + "/.noderc"+ extention , __dirname +"/../../.noderc.js" ];
27
28    // Parse any existing files within config list & merge them
29    for (var idx in files) { 
30       if (files[idx]) {
31         //console.log ("files=", files[idx]);  
32         if (fs.existsSync (files[idx])) conf=require (files[idx]);
33         for (var i in conf) values[i] = conf[i];
34       }     
35    }
36    
37  // set path to search for node_module within parent directory
38  process.env.NODE_PATH= process.env.NODE_PATH + '../node_modules';
39    
40  // console.log ("values=", values);
41  return values;
42 }
43
44 module.exports = Config();