mirror of
https://github.com/sexybiggetje/pixdisp.git
synced 2024-11-22 09:11: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';
|
'use strict';
|
||||||
|
|
||||||
let fs = require( 'fs' );
|
let fs = require( 'fs' );
|
||||||
let config;
|
let os = require( 'os' );
|
||||||
let api;
|
|
||||||
|
let config,
|
||||||
|
api,
|
||||||
|
contents;
|
||||||
|
|
||||||
if ( fs.existsSync( 'config.json' ) ) {
|
if ( fs.existsSync( 'config.json' ) ) {
|
||||||
let contents = fs.readFileSync( 'config.json' );
|
contents = fs.readFileSync( 'config.json' );
|
||||||
config = JSON.parse( contents );
|
} else if ( fs.existsSync( os.homedir() + '/.pixdisp/config.json' ) ) {
|
||||||
|
contents = fs.readFileSync( os.homedir() + '/.pixdisp/config.json' );
|
||||||
} else {
|
} else {
|
||||||
let contents = fs.readFileSync( 'config.example.json' );
|
contents = fs.readFileSync( 'config.example.json' );
|
||||||
config = JSON.parse( contents );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( typeof contents === 'undefined' ||
|
||||||
|
contents === false || contents === undefined ||
|
||||||
|
contents === '' ) {
|
||||||
|
|
||||||
|
console.log( 'Invalid or no configuration' );
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
config = JSON.parse( contents );
|
||||||
|
|
||||||
let driver;
|
let driver;
|
||||||
let { DriverFactory } = require( './drivers/driverfactory' );
|
let { DriverFactory } = require( './drivers/driverfactory' );
|
||||||
let driverFactory = new DriverFactory();
|
let driverFactory = new DriverFactory();
|
||||||
|
|
Loading…
Reference in a new issue