From edcc3ad75765255fb18302f50cc3d38814287680 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 | 3 +++ 2 files changed, 4 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..c4186be 100644 --- a/lights.js +++ b/lights.js @@ -1,5 +1,8 @@ import * as ws281x from 'rpi-ws281x' +if (!global.cfg) { + global.cfg = {} +} const fade_ticks = global.cfg.fade_ticks || 10; var pixels = new Uint32Array(global.cfg.leds); var pixel_cache = new Uint32Array(global.cfg.leds);