Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm programming with nodeJS. After I edit my code, I have to:

  1. Save the code in TextMate: cmd+s

  2. Shut down the server in bash: cmd+c

  3. Restart the server in bash: node myCode.js

  4. Refresh Google Chrome: cmd+r

Doing these steps over and over is quite repetitive. Is there a way to program my computer (mac OS X) to do all these steps in one go?

share|improve this question

migrated from stackoverflow.com Nov 11 '11 at 16:58

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers

up vote 5 down vote accepted

I don't know about the google chrome refresh but I use the 'node-dev' package via npm (npm install -g node-dev) and then run: node-dev app.js

It watches all of your files and restarts your node process each time the files change, eliminating steps 2+3.

Here's the Github link if you prefer not to use npm: https://github.com/fgnass/node-dev

(edit: Updated npm install command to include -g per HE's advice below)

share|improve this answer
    
Thanks Brad. Very helpful. –  Randomblue Aug 6 '11 at 22:28
    
I get the following error npm WARN prefer global node-dev@0.1.8 should be installed with -g –  Randomblue Aug 6 '11 at 22:32
1  
You should run npm install node-dev -g. This installs the package into the global node prefix, so that it is available anywhere on the system. –  Jon Gauthier Aug 6 '11 at 22:33
add comment

Check out keyboard maestro for general UI automation and scripting. You may also want to look into the nodemon npm module which will restart your node.js server whenever a file changes. In practice, nodemon hasn't been a workable solution for me, though. It's similar to the node-dev package Brad suggested.

share|improve this answer
1  
Why was nodemon not a workable solution for you? –  Randomblue Aug 7 '11 at 6:32
    
None of these approaches AFAIK are intelligent about when to restart the app. So, for example, my system tests are running and I save a file, it will restart the app under my systems tests, sometimes leaving stale data in the DB. It's just a very blunt/dumb approach. It can be helpful but it's not a great solution. I've fallen back to setting up a Keyboard Maestro macro that manually kills and restarts the server when I want. –  Peter Lyons Aug 7 '11 at 13:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.