mirror of
https://github.com/sexybiggetje/pixdisp.git
synced 2024-11-21 21:51:02 +01:00
Config lookup
This commit is contained in:
parent
7f9c8d1c45
commit
aea974387d
1 changed files with 19 additions and 6 deletions
25
pixdisp.js
25
pixdisp.js
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue