lib/utils/fs.js
function listFiles(root, options) {
    options = _.defaults(options || {}, {
        ignoreFiles: [],
        ignoreRules: []
    });

    var d = Q.defer();

    // Our list of files
    var files = [];

    var ig = Ignore({
        path: root,
        ignoreFiles: options.ignoreFiles
    });

    // Add extra rules to ignore common folders
    ig.addIgnoreRules(options.ignoreRules, '__custom_stuff');

    // Push each file to our list
    ig.on('child', function (c) {
        files.push(
            c.path.substr(c.root.path.length + 1) + (c.props.Directory === true ? '/' : '')
        );
    });

    ig.on('end', function() {
        // Normalize paths on Windows
        if(process.platform === 'win32') {
            return d.resolve(files.map(function(file) {
                return file.replace(/\\/g, '/');
            }));
        }

        // Simply return paths otherwise
        return d.resolve(files);
    });

    ig.on('error', d.reject);

    return d.promise;
}
function listFiles(root, options) {
    options = _.defaults(options || {}, {
        ignoreFiles: [],
        ignoreRules: []
    });

    var d = Q.defer();

    // Our list of files
    var files = [];

    var ig = Ignore({
        path: root,
        ignoreFiles: options.ignoreFiles
    });

    // Add extra rules to ignore common folders
    ig.addIgnoreRules(options.ignoreRules, '__custom_stuff');

    // Push each file to our list
    ig.on('child', function (c) {
        files.push(
            c.path.substr(c.root.path.length + 1) + (c.props.Directory === true ? '/' : '')
        );
    });

    ig.on('end', function() {
        // Normalize paths on Windows
        if(process.platform === 'win32') {
            return d.resolve(files.map(function(file) {
                return file.replace(/\\/g, '/');
            }));
        }

        // Simply return paths otherwise
        return d.resolve(files);
    });

    ig.on('error', d.reject);

    return d.promise;
}
function listFiles ( root , options ) { options = _ . defaults ( options || { } , { ignoreFiles : [ ] , ignoreRules : [ ] } ) ; var d = Q . defer ( ) ; // Our list of files var files = [ ] ; var ig = Ignore ( { path : root , ignoreFiles : options . ignoreFiles } ) ; // Add extra rules to ignore common folders ig . addIgnoreRules ( options . ignoreRules , '__custom_stuff' ) ; // Push each file to our list ig . on ( 'child' , function ( c ) { files . push ( c . path . substr ( c . root . path . length + 1 ) + ( c . props . Directory === true ? '/' : '' ) ) ; } ) ; ig . on ( 'end' , function ( ) { // Normalize paths on Windows if ( process . platform === 'win32' ) { return d . resolve ( files . map ( function ( file ) { return file . replace ( / \\ / g , '/' ) ; } ) ) ; } // Simply return paths otherwise return d . resolve ( files ) ; } ) ; ig . on ( 'error' , d . reject ) ; return d . promise ; }
List files in a directory
List files in a directory