Git Product home page Git Product logo

watch.js's Introduction

watch.js

This is a node.js script that watches local files and keeps them updated on a remote server. It requires node.js, rsync, and a server that allows password-less login via SSH keys.

watch.js source destination
   -i,    --identity=ARG        Specify id_rsa file location (default: `~/.ssh/id_rsa`).
   -t,    --time=ARG            The minimum time period between successive rsyncs (default: 250 ms).
   -d,    --delete              Delete extraneous files on the remote (dangerous).
   -h,    --help                Display this help.

Example Output:

On every file change, it'll perform an rsync:

> watch.js ../a3/ [email protected]:/home/rsnara/cs240/a3
rsync #1 [SUCCESS]: ./, asm.cc, kind.cc, kind.h, lexer.cc, lexer.h, traverse.cc, old/, old/asm.cc
rsync #2 [SUCCESS]: asm.cc, kind.cc
rsync #3 [SUCCESS]: lexer.cc, traverse.cc, old/

Installation ============

Grab node.js and install Cygwin with rsync and ssh-keygen.

Once you have all three things installed, clone the repository and install the npm modules:

> git clone https://github.com/ramanpreetnara/watch.js.git path/to/repo
> cd path/to/repo && npm install

NOTE: You can also add path/to/repo into your PATH environment variable to make the script easier to execute.


Server Configuration: ====================

NOTE: To use this script, your server must allow password-less login via SSH Keys. If that's already set up, feel free skip this section.

We'll generate two files: id_rsa and id_rsa.pub using ssh-keygen. This script requires the generated keys to not be password protected. Be careful.

# follow the instructions
> ssh-keygen

Now, append the contents of newly generated id_rsa.pub to the file ~/.ssh/authorized_keys on your server.

# copy over the file (fill in the details here)
> scp ~/.ssh/id_rsa.pub username@server:/temporary/location/id_rsa.pub

# SSH into the server
> ssh username@server

# append to ~/.ssh/authorized_keys
> echo '' >> ~/.ssh/authorized_keys
> cat /temporary/location/id_rsa.pub >> ~/.ssh/authorized_keys

To test to see if the key works, simply run watch.js source destination.

NOTE: You can also generate a private key using PuTTYgen and try to log in via PuTTY (using the private key). If the key doesn't work, feel free to post an issue (after doing some digging around on Google, that is).


Special thanks: ===============

This script builds on the following three node projects:

getopt - a command line parser that makes the script easier to run
node-rsync - building and executing rsync commands with Node.js.
async - async flow-control module for Node.js.

Notices:

This script relies on fs.watch, which is currently unstable.

watch.js's People

Contributors

rsnara avatar

Watchers

James Cloos avatar Clement Hoang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.