src/utils/index.js
function getInputSources(pathname, callback) {
  let filesRead = 0;
  let sources = {};

  // test file is a file, the last section contains a extention period
  if (String(pathname).split('/').pop().indexOf('.') !== -1) {
    const searchPathname = pathname.substr(0, 2) === './' ? pathname.slice(2) : pathname;

    fs.readFile(searchPathname, 'utf8', (readFileError, fileData) => { // eslint-disable-line
      if (readFileError) {
        return callback(error(`while while getting input sources ${readFileError}`));
      }

      callback(null, { [searchPathname]: fileData });
    });
  } else {
    // get all file names
    dir.files(pathname, (filesError, files) => { // eslint-disable-line
      if (filesError) {
        return callback(error(`while while getting input sources ${filesError}`));
      }

      // if no files in directory, then fire callback with empty sources
      if (files.length === 0) {
        callback(null, sources);
      } else {
        // read all files
        dir.readFiles(pathname, (readFilesError, content, filename, next) => { // eslint-disable-line
          if (readFilesError) {
            return callback(error(`while getting input sources ${readFilesError}`));
          }

          // add input sources to output
          sources = Object.assign({}, sources, {
            [path.join('./', filename)]: content,
          });

          // increase files readFiles
          filesRead += 1;

          // process next file
          if (filesRead === files.length) {
            callback(null, sources);
          } else {
            next();
          }
        });
      }
    });
  }
}
function getInputSources(pathname, callback) {
  let filesRead = 0;
  let sources = {};

  // test file is a file, the last section contains a extention period
  if (String(pathname).split('/').pop().indexOf('.') !== -1) {
    const searchPathname = pathname.substr(0, 2) === './' ? pathname.slice(2) : pathname;

    fs.readFile(searchPathname, 'utf8', (readFileError, fileData) => { // eslint-disable-line
      if (readFileError) {
        return callback(error(`while while getting input sources ${readFileError}`));
      }

      callback(null, { [searchPathname]: fileData });
    });
  } else {
    // get all file names
    dir.files(pathname, (filesError, files) => { // eslint-disable-line
      if (filesError) {
        return callback(error(`while while getting input sources ${filesError}`));
      }

      // if no files in directory, then fire callback with empty sources
      if (files.length === 0) {
        callback(null, sources);
      } else {
        // read all files
        dir.readFiles(pathname, (readFilesError, content, filename, next) => { // eslint-disable-line
          if (readFilesError) {
            return callback(error(`while getting input sources ${readFilesError}`));
          }

          // add input sources to output
          sources = Object.assign({}, sources, {
            [path.join('./', filename)]: content,
          });

          // increase files readFiles
          filesRead += 1;

          // process next file
          if (filesRead === files.length) {
            callback(null, sources);
          } else {
            next();
          }
        });
      }
    });
  }
}
function getInputSources ( pathname , callback ) { let filesRead = 0 ; let sources = { } ; // test file is a file, the last section contains a extention period if ( String ( pathname ) . split ( '/' ) . pop ( ) . indexOf ( '.' ) !== - 1 ) { const searchPathname = pathname . substr ( 0 , 2 ) === './' ? pathname . slice ( 2 ) : pathname ; fs . readFile ( searchPathname , 'utf8' , ( readFileError , fileData ) => { // eslint-disable-line if ( readFileError ) { return callback ( error ( ` ${ readFileError } ` ) ) ; } callback ( null , { [ searchPathname ] : fileData } ) ; } ) ; } else { // get all file names dir . files ( pathname , ( filesError , files ) => { // eslint-disable-line if ( filesError ) { return callback ( error ( ` ${ filesError } ` ) ) ; } // if no files in directory, then fire callback with empty sources if ( files . length === 0 ) { callback ( null , sources ) ; } else { // read all files dir . readFiles ( pathname , ( readFilesError , content , filename , next ) => { // eslint-disable-line if ( readFilesError ) { return callback ( error ( ` ${ readFilesError } ` ) ) ; } // add input sources to output sources = Object . assign ( { } , sources , { [ path . join ( './' , filename ) ] : content , } ) ; // increase files readFiles filesRead += 1 ; // process next file if ( filesRead === files . length ) { callback ( null , sources ) ; } else { next ( ) ; } } ) ; } } ) ; } }
Get all input source for a specific pathname, used for mapping config entry

@method getInputSources
@param {String} pathname a path string to a file or directory
@param {Function} callback the final callback that returns the sources
@callback {Object} sourceMap returns a source map for this pathname
Get all input source for a specific pathname used for mapping config entry