Commits

Andreas Knecht committed 55d98aa

Improvements to file watching.

Comments (0)

Files changed (1)

lib/soycompiler.js

         javaProcess.on('exit', function (exitCode) {
             if (exitCode != 0) {
                 console.error('Soy Compilation Error: ', stderr);
-                cb(new Error('Soy Compilation Error: ' + stderr));
+                return cb(new Error('Soy Compilation Error: ' + stderr));
             }
             cb();
         });
 
                 try {
                     autoCompileTime[fullPath] = Date.now();
-                    fs.watch(fullPath, {}, function (e, f) {
+                    fs.watchFile(fullPath, {}, function (e, f) {
                         var now = Date.now();
                         console.log('Autorecompiling soy templates due to file change in ' + fullPath);
                         autoCompileTime[fullPath] = now;
-                        compileTemplates(options, cb);
+                        compileTemplates(options, function(err) {
+                            if(err) {
+                                console.error("Error autocompiling templates.");
+                            } else {
+                                console.log("Autocompiled soy templates.")
+                            }
+                        });
                     });
                 } catch (e) {
                     console.warn('Error with fs.watch ' + fullPath, e)