From c6446de63c5d528fd2ea2bcf104c4f7d23efe6b2 Mon Sep 17 00:00:00 2001 From: Jane Petrovna Date: Tue, 25 May 2021 23:20:35 -0400 Subject: [PATCH] error catching for cfg --- index.js | 2 +- lights.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index eaef78d..82695a4 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,7 @@ import * as lights from './lights.js'; const cfg = require('./config.json'); -global.cfg = cfg; +global.cfg = cfg || {}; server.recv( (res) => { diff --git a/lights.js b/lights.js index bf5ba0b..f6f891d 100644 --- a/lights.js +++ b/lights.js @@ -1,5 +1,10 @@ import * as ws281x from 'rpi-ws281x' +if (!global.cfg) { + const cfg = require('./config.json'); + + global.cfg = cfg || {}; +} const fade_ticks = global.cfg.fade_ticks || 10; var pixels = new Uint32Array(global.cfg.leds); var pixel_cache = new Uint32Array(global.cfg.leds);