lib/config-generator.js
function() {
        var self = this;

        self._modules = [];

        return new Promise(function(resolve, reject) {
            var base;
            var processors = [];

            if (self._options.base) {
                base = fs.readFileSync(path.resolve(self._options.base), 'utf8');
            }

            // For every file or folder, create a promise,
            // parse the file, extract the config and store it
            // to the global modules array.
            // Once all files are being processed, store the generated config.
            for (var i = 0; i < self._options.args.length; i++) {
                var file = self._options.args[i];

                var fileStats = fs.statSync(file);

                if (fileStats.isDirectory(file)) {
                    var walker = walk.walk(file, {
                        followLinks: false
                    });

                    walker.on('file', self._onWalkerFile.bind(self));

                    processors.push(self._onWalkerEnd(walker));
                } else if (fileStats.isFile()) {
                    processors.push(self._processFile(file));
                }
            }

            Promise.all(processors)
                .then(function(uselessPromises) {
                    return self._generateConfig();
                })
                .then(function(config) {
                    var content;

                    if (self._options.config) {
                        if (base) {
                            content = base + self._options.config + '.modules = ' + JSON.stringify(config) + ';';
                        } else {
                            content = 'var ' + self._options.config + ' = {modules: ' + JSON.stringify(config) + '};';
                        }
                    } else {
                        content = JSON.stringify(config);
                    }

                    return self._saveConfig(beautify(content));
                })
                .then(function(config) {
                    resolve(config);
                })
                .catch(function(error) {
                    reject(error);
                });
        });
    }
function() {
        var self = this;

        self._modules = [];

        return new Promise(function(resolve, reject) {
            var base;
            var processors = [];

            if (self._options.base) {
                base = fs.readFileSync(path.resolve(self._options.base), 'utf8');
            }

            // For every file or folder, create a promise,
            // parse the file, extract the config and store it
            // to the global modules array.
            // Once all files are being processed, store the generated config.
            for (var i = 0; i < self._options.args.length; i++) {
                var file = self._options.args[i];

                var fileStats = fs.statSync(file);

                if (fileStats.isDirectory(file)) {
                    var walker = walk.walk(file, {
                        followLinks: false
                    });

                    walker.on('file', self._onWalkerFile.bind(self));

                    processors.push(self._onWalkerEnd(walker));
                } else if (fileStats.isFile()) {
                    processors.push(self._processFile(file));
                }
            }

            Promise.all(processors)
                .then(function(uselessPromises) {
                    return self._generateConfig();
                })
                .then(function(config) {
                    var content;

                    if (self._options.config) {
                        if (base) {
                            content = base + self._options.config + '.modules = ' + JSON.stringify(config) + ';';
                        } else {
                            content = 'var ' + self._options.config + ' = {modules: ' + JSON.stringify(config) + '};';
                        }
                    } else {
                        content = JSON.stringify(config);
                    }

                    return self._saveConfig(beautify(content));
                })
                .then(function(config) {
                    resolve(config);
                })
                .catch(function(error) {
                    reject(error);
                });
        });
    }
function ( ) { var self = this ; self . _modules = [ ] ; return new Promise ( function ( resolve , reject ) { var base ; var processors = [ ] ; if ( self . _options . base ) { base = fs . readFileSync ( path . resolve ( self . _options . base ) , 'utf8' ) ; } // For every file or folder, create a promise, // parse the file, extract the config and store it // to the global modules array. // Once all files are being processed, store the generated config. for ( var i = 0 ; i < self . _options . args . length ; i ++ ) { var file = self . _options . args [ i ] ; var fileStats = fs . statSync ( file ) ; if ( fileStats . isDirectory ( file ) ) { var walker = walk . walk ( file , { followLinks : false } ) ; walker . on ( 'file' , self . _onWalkerFile . bind ( self ) ) ; processors . push ( self . _onWalkerEnd ( walker ) ) ; } else if ( fileStats . isFile ( ) ) { processors . push ( self . _processFile ( file ) ) ; } } Promise . all ( processors ) . then ( function ( uselessPromises ) { return self . _generateConfig ( ) ; } ) . then ( function ( config ) { var content ; if ( self . _options . config ) { if ( base ) { content = base + self . _options . config + '.modules = ' + JSON . stringify ( config ) + ';' ; } else { content = 'var ' + self . _options . config + ' = {modules: ' + JSON . stringify ( config ) + '};' ; } } else { content = JSON . stringify ( config ) ; } return self . _saveConfig ( beautify ( content ) ) ; } ) . then ( function ( config ) { resolve ( config ) ; } ) . catch ( function ( error ) { reject ( error ) ; } ) ; } ) ; }
Processes the passed files or folders and generates config file.

@method process
@return {Promise} Returns a Promise which will be resolved with the generated config file
Processes the passed files or folders and generates config file .