Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

init

  • Loading branch information...
commit af5914e2d02275ab9ce47e47d6714a2df80e7e96 1 parent beb1c78
Ting-Yen Lai authored February 19, 2013

Showing 2 changed files with 50 additions and 0 deletions. Show diff stats Hide diff stats

  1. 31  main.js
  2. 19  package.json
31  main.js
... ...
@@ -0,0 +1,31 @@
  1
+var fs = require('fs');
  2
+var exec = require('child_process').exec;
  3
+var path = require('path');
  4
+var util = require('util');
  5
+
  6
+var target = process.argv[2];
  7
+var command = process.argv[3];
  8
+
  9
+var find = function (target, callback) {
  10
+    exec('find . -regex ' + target, function (error, stdout) {
  11
+        if (error) throw error;
  12
+        var paths = stdout.trim().split('\n').map(path.normalize);
  13
+        callback(error, paths);
  14
+    });
  15
+};
  16
+
  17
+var execute = function () {
  18
+    exec(command, function (error, stdout, stderr) {
  19
+        if (stdout)
  20
+            console.log(stdout.trim());
  21
+        if (stderr)
  22
+            console.log(stderr.trim());
  23
+    });
  24
+};
  25
+
  26
+find(target, function (error, paths) {
  27
+    if (error) throw error;
  28
+    paths.forEach(function (filename) {
  29
+        fs.watch(filename, execute);
  30
+    });
  31
+});
19  package.json
... ...
@@ -0,0 +1,19 @@
  1
+{
  2
+  "name": "watchr",
  3
+  "version": "0.0.1",
  4
+  "description": "watchr",
  5
+  "main": "main.js",
  6
+  "repository": {
  7
+    "type": "git",
  8
+    "url": "https://github.com/banacorn/watchr.git"
  9
+  },
  10
+  "bin": {
  11
+    "watchr": "bin/watchr"
  12
+  },
  13
+  "keywords": [
  14
+    "watchr"
  15
+  ],
  16
+  "author": "Ting-Yen LAI",
  17
+  "license": "MIT",
  18
+  "readmeFilename": "README.md"
  19
+}

0 notes on commit af5914e

Please sign in to comment.
Something went wrong with that request. Please try again.