GPIO Buttons - Add a status LED

I’m using the GPIO buttons plugin with this mod to allow me to use a series of momentary switches to select internet radio stations. This is working well. However, I’d like to take it to the next step. I’ve selected switches with an internal led and I’d like to light this for the active station.

I’m pretty novice at scripting, but it looks to me like this code in index.js is being executed when I press a button on the relevant GPIO pin:

//next on playlist
GPIOButtons.prototype.next = function() {
  //this.logger.info('GPIO-Buttons: next-button pressed');
  socket.emit('next')
};

It seems to me that I could add some simple code to turn an LED on when this code is run:

//next on playlist
GPIOButtons.prototype.next = function() {
  
  var LED = new Gpio(4, 'out');
  LED.writeSync(1);
  
  //this.logger.info('GPIO-Buttons: next-button pressed');
  socket.emit('next')
};

That should turn on GPIO pin 4 when I push the button I think. It’s not doing anything though, not even an error in the logs. How can I get started debugging this? Is there a better way to do it?

Now, I know there are problems with the code. It is not at all complete. I’m just starting with a proof of concept and I’ll refine the rest later.

Argh. After a bunch of troubleshooting I restarted the thing and this works. So, good news, I’ve got some working status LED’s!