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

Statements: 100% (11 / 11)      Branches: 87.5% (7 / 8)      Functions: 100% (2 / 2)      Lines: 100% (10 / 10)      Ignored: none     

All files » stylus-lint/src/ » read.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 28 29 30 31 32 33 34    1               1     5 1               4 4   2 1   1 1        
'use strict';
 
var fs = require('fs');
 
/**
 * @description determines what files to read, creates an array of them, and passes it to be parsed
 * @param {object} [app] [basically the whole app]
 * @param {string} [dir] [shorthand for app.state.dir, param so its easier to test]
 * @returns parse function
 */
module.exports = function read( app, path ) {
    // if nothing passed in, default to linting the curr dir
    // here we get all the files to parse first, then we pass to app.parse
    if ( path === process.cwd() ) {
        app.getFiles( path + '/**/*.styl' );
    }
 
    /**
     * else we'll have either a filename or dir name to work with
     * if directory we use the glob logic to return an array of files to test
     */
    else {
        fs.stat(path, function( err, stats ) {
            if ( err ) { throw err; }
 
            if ( stats.isFile() ) {
                return app.parseFile( app, path, 1, 1 );
            }
            else Eif ( stats.isDirectory() ) {
                app.getFiles( path + '/**/*.styl' );
            }
        });
    }
}