NodeDomain lesson with Adobe Brackets
February 12, 2015
3 min read
The first extension I’m building is Sencha Cmd integration. I normally have my editor and iTerm open at the same time. With iTerm I normally have a couple tabs open, one to start my node server and another to run builds with Cmd. So I wanted to be able to run a Cmd build within Brackets so that I don’t have to switch back to iTerm to run a build.
Being my first extension, I had to look around at existing plugins that can execute commands such as hdy.brackets-shell extension. I learned that I have to create a NodeDomain spec to be able to use Node.js’ child_process module. This made me learn a bit of how Brackets work. It turns out that Brackets has a Node.js server running behind the scenes which you can communicate with via NodeDomain which uses NodeConnection (you can also have NodeConnection create the NodeDomain so you can go at it either way). NodeConnection then uses websockets to communicate from the client web app that you interact with and the Node.js server. I got a basic setup working but I was beating my head against my desk wondering why when I make a change to my NodeDomain spec that I wasn’t seeing it applied when I would reload Brackets with extensions (cmd + r keyboard shortcut on Mac). Turns out when you reload Brackets, you are only really reloading the client web app, not the Node.js server which needs to happen to make your NodeDomain spec changes take affect.
So the solution is to either quit Brackets and start it back up or you can restart Node via the Debug -> Restart Node menu item. I wish there was an option to reload Brackets and restart Node with a single menu item. Guess a new extension for this is on my list.
Written by Mitchell Simoens who is a long time nerd developing software and building computers and gadgets. Anything expressed on this website are Mitchell Simoens's alone and do not represent his employer.