1
0
Fork 0
mirror of https://github.com/sexybiggetje/pixdisp.git synced 2024-11-22 03:31:03 +01:00

Config lookup

This commit is contained in:
Martijn de Boer 2018-01-05 15:26:03 +01:00
parent 7f9c8d1c45
commit aea974387d

View file

@ -1,17 +1,30 @@
'use strict';
let fs = require( 'fs' );
let config;
let api;
let os = require( 'os' );
let config,
api,
contents;
if ( fs.existsSync( 'config.json' ) ) {
let contents = fs.readFileSync( 'config.json' );
config = JSON.parse( contents );
contents = fs.readFileSync( 'config.json' );
} else if ( fs.existsSync( os.homedir() + '/.pixdisp/config.json' ) ) {
contents = fs.readFileSync( os.homedir() + '/.pixdisp/config.json' );
} else {
let contents = fs.readFileSync( 'config.example.json' );
config = JSON.parse( contents );
contents = fs.readFileSync( 'config.example.json' );
}
if ( typeof contents === 'undefined' ||
contents === false || contents === undefined ||
contents === '' ) {
console.log( 'Invalid or no configuration' );
process.exit();
}
config = JSON.parse( contents );
let driver;
let { DriverFactory } = require( './drivers/driverfactory' );
let driverFactory = new DriverFactory();