How to use the watchr.watch function in watchr

To help you get started, we’ve selected a few watchr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Illizian / node-codekit / lib / node-codekit.js View on Github external
function watchInit() {
	console.log(ascii.color('\n    )     )  (               )  (            ', 'yellow'));
	console.log(ascii.color(' ( /(  ( /(  )\\ )         ( /(  )\\ )  *   )  ', 'red'));
	console.log(ascii.color(' )\\()) )\\())(()/(   (     )\\())(()/(` )  /(  ', 'red'));
	console.log(ascii.color('((_)\\ ((_)\\  /(_))  )\\  |((_)\\  /(_))( )(_)) ', 'red'));
	console.log(ascii.color(' _((_)  ((_)(_))_  ((_) |_ ((_)(_)) (_(_())  ', 'blue'));
	console.log(ascii.color('| \\| | / _ \\ |   \\ | __|| |/ / |_ _||_   _|  ', 'cyan'));
	console.log(ascii.color('| .` || (_) || |) || _|   \' <   | |   | |    ', 'cyan'));
	console.log(ascii.color('|_|\\_| \\___/ |___/ |___| _|\\_\\ |___|  |_|    ', 'cyan'));
	console.log(ascii.color('\n A Web Developer\'s Best Friend! \n', 'bold'))
	
	console.log('Watching: ' + process.cwd());
	notify('NodeKit', 'Watching: ' + process.cwd());
	// Watch the current working directory
	watchr.watch({
	    path: process.cwd(),
	    listener: function(eventName,filePath,fileCurrentStat,filePreviousStat) {
	        // Handle watch event
	        pre_process([eventName,filePath,fileCurrentStat,filePreviousStat]);
	    },
	    next: function(err,watcher) {
	        if (err)  throw err;
	    }
	});
	// Listen on socket channel
	io = require('socket.io').listen(8080)
	
	// Socket.IO configuration
	io.set('log level', 0);

	// Attach Socket.IO Events
github CodeboxIDE / codebox / core / cb.watch / init.js View on Github external
function init(logger, events, rootPath) {
    var d = Q.defer();

    // Normalize paths
    function normalize(fullPath) {
        return path.normalize(
            '/' + path.relative(rootPath, fullPath)
        );
    }

    logger.log('Starting Watch');
    // Construct
    watchr.watch({
        paths: [rootPath],

        // Following links causes issues with broken symlinks
        // crashing the whole watchr instance and thus codebox
        // so disabling link following for now
        followLinks: false,

        listeners: {
            log: function(logLevel) {
                /*
                events.emit('watch.log', {
                    level: logLevel,
                    args: _.toArray(arguments)
                });
                */
            },
github digiwano / auton / lib / watcher.js View on Github external
paths: this.paths,
    listeners: { // forward everything on to our eventemitter for now
      log      : function(level, info) {
        self.log( level === 'debug' ? 'debug-2' : level, info );
      },
      error    : this.emit.bind( this, 'error' ),
      change   : _change.bind( this )
    },
    next: function(err, watchers) {
      if (err) { this.emit('error', err); return callback(err); }
      self.watchers = watchers;
      self.log('debug', 'watching ' + self.watchers.length + ' files/dirs');
    }
  };
  var cfg = _.extend( {}, _defaultConfig, this.config )
  watchr.watch( cfg );
};
github CodeboxIDE / codebox / core / cb.watch / init.js View on Github external
function init(logger, events, rootPath) {
    var d = Q.defer();

    // Normalize paths
    function normalize(fullPath) {
        return path.normalize(
            '/' + path.relative(rootPath, fullPath)
        );
    }

    logger.log('Starting Watch');
    // Construct
    watchr.watch({
        paths: [rootPath],

        // Following links causes issues with broken symlinks
        // crashing the whole watchr instance and thus codebox
        // so disabling link following for now
        followLinks: false,

        listeners: {
            log: function(logLevel) {
                /*
                events.emit('watch.log', {
                    level: logLevel,
                    args: _.toArray(arguments)
                });
                */
            },
github ITEA3-Measure / MeasurePlatform / src / main / webapp / bower_components / messageformat / bin / messageformat.js View on Github external
},
      function() {
        var fn_str = mf.compile(messages, compileOpt).toString();
        fn_str = fn_str.replace(/^\s*function\b[^{]*{\s*/, '').replace(/\s*}\s*$/, '');
        var data = options.module ? fn_str : '(function(G) {\n' + fn_str + '\n})(this);';
        return callback(options, data.trim() + '\n');
      }
    );
  });
}

build(options, write);

if (options.watch) {
  _log('watching for changes in ' + options.inputdir + '...\n');
  require('watchr').watch({
    path: options.inputdir,
    ignorePaths: [ options.output ],
    listener: function(changeType, filePath) { if (/\.json$/.test(filePath)) build(options, write); }
  });
}
github howech / gestalt / lib / file.js View on Github external
}

    if( format ) {
	if( format != 'raw' ) {
	    this._options_.parser = this._options_.parser || parsers[ format ];
	} else {
	    this._options_parser = parsers[ 'rawFile' ];
	}
    }


    //console.log( "options: ", this._options_ );
    this.readFile();

    if( this._options_.watch ) {  
	this._watchr_ = watchr.watch( 
	    { path: this._source_,
	      listener: function(event, file, stat, ostat) {
		  if( event == 'change' ) {
		      self.readFile();
		  } else if (event == 'unlink' ) {
		      self.state('invalid', 'backing file deleted;');
		  }
	      }
	    });
    }
}
github austinsc / signal-arr-proxygen / src / cli.js View on Github external
.argv;

if(argv._.length < 2) {
  CFonts.say(' signal-arr', {colors: ['red', 'white'], maxLength: '11'});
  yargs.showHelp('log');
} else {
  argv.command = argv._[0];
  argv.assembly = argv._[1];
  argv.print = console.log;
  argv.writeFile = fs.writeFile;
  argv.readFile = fs.readFile;
  if(argv.command === 'interactive') {
    interactive(argv).catch(err => console.error(err));
  } else {
    if(argv.watch) {
      watchr.watch({
        path: argv.assembly,
        listener() {
          processor(argv).catch(err => console.error(err));
        }
      });
    }
    processor(argv).catch(err => console.error(err));
  }
}
github Raynos / live-reload / index.js View on Github external
function LiveReloadServer(options) {
    var server = http.createServer(serveText)
        , sock = shoe(handleStream)
        , paths = options._ || process.cwd()
        , filterIgnored = options.ignore || noop
        , delay = options.delay || 1000
        , port = options.port || 9090
        , timer
        , source = bundle(path.join(__dirname, "reload.js"), {
            body: "require('./browser.js')(" + port + ")"
        })

    watchr.watch({
        paths: paths
        , listener: reload
        , ignoreHiddenFiles: true
        , ignorePatterns: true
    })

    sock.install(server, "/shoe")

    server.listen(port)

    console.log("live reload server listening on port", port
        , "reloading on files")


    function serveText(req, res) {
        res.setHeader("content-type", "application/javascript")
github wookiehangover / universal-jst / bin / jst.js View on Github external
}

function write( data, callback ){
  data = data.join('\n');
  if(options.stdout) {
    return console.log(data);
  }
  var output = options.output;
  fs.writeFile( output, data, 'utf8', function( err ){
    if( typeof callback == "function" ) callback(err, output);
  });
};

compile();
if(options.watch){
  return watch(options.inputdir, _.debounce(compile, 100));
}
github simontabor / serenity / serenity.js View on Github external
cli.info('Just booted. Regenerating.');
  var start = Date.now();

  walk(root,reg,ignore,function(err,files) {
    for (var i = 0; i < files.length; i++) {
      files[i] = files[i].replace(root,'.');
    }
    generator = new Generator(files, config, function() {
      cli.ok('Generated site in ' + (Date.now() - start) + 'ms');
      if (!options['no-server']) return;

      cli.info('Exiting');
      process.exit();
    });
  });
  watchr.watch(config.watchr);


});

watchr

Better file system watching for Node.js

MIT
Latest version published 3 years ago

Package Health Score

57 / 100
Full package analysis