Code coverage report for stylus-lint/src/watch.js

Statements: 70% (7 / 10)      Branches: 50% (1 / 2)      Functions: 66.67% (2 / 3)      Lines: 77.78% (7 / 9)      Ignored: none     

All files » stylus-lint/src/ » watch.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27    1                   1 1 1     1 1       1        
'use strict';
 
var
    chalk    = require('chalk'),
    chokidar = require('chokidar');
 
/**
 * kicks off the app. sets up config and kicks off reading the files
 * @param  {string} dir          [dir | filename | 'nothing']
 * @param  {string} customConfig [path to config object]
 * @return {function}            [kick off linter on each change]
 */
module.exports = function watch( app, path ) {
    Iif ( typeof path === 'undefined' ) { return; }
    var watcher = chokidar.watch( path );
 
    // initial watch msg
    watcher.on('ready', function() {
        return console.log( chalk.blue('Watching: '), path, ' for changes.' );
    });
 
    // listen for changes, update 'dir' to curr file, do somethin
    watcher.on('change', function( newPath ) {
        app.state.dir = newPath;
        return app.read( app, newPath );
    });
}