src/utils/index.js
function getInputSources(dirname, exclude, include, focusContractPath, callback) {
  let filesRead = 0;
  const sources = {};

  // get all file names
  dir.files(dirname, (filesError, files) => {
    if (filesError) {
      throwError(`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(dirname, (readFilesError, content, filename, next) => {
        if (readFilesError) {
          throwError(`while getting input sources ${readFilesError}`);
        }

        // parsed filename
        const parsedDirName = dirname.replace('./', '');
        const parsedFileName = filename.replace(parsedDirName, '').replace(/^\//, '');
        const onlyFilename = filename.substr(filename.lastIndexOf('/') + 1);

        // add input sources to output
        if (filename.substr(filename.lastIndexOf('.') + 1) === 'sol'
          && filenameInclude(filename, exclude, include)
          && onlyFilename.charAt(0) !== '~'
          && onlyFilename.charAt(0) !== '#'
          && onlyFilename.charAt(0) !== '.') {
          sources[parsedFileName] = content;
        }

        // increase files readFiles
        filesRead += 1;

        // process next file
        if (filesRead === files.length) {
          // filter sources by focus dependencies
          if (focusContractPath) {
            callback(null, buildDependantsSourceTree(focusContractPath, sources));
          } else {
            callback(null, sources);
          }
        } else {
          next();
        }
      });
    }
  });
}
function getInputSources(dirname, exclude, include, focusContractPath, callback) {
  let filesRead = 0;
  const sources = {};

  // get all file names
  dir.files(dirname, (filesError, files) => {
    if (filesError) {
      throwError(`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(dirname, (readFilesError, content, filename, next) => {
        if (readFilesError) {
          throwError(`while getting input sources ${readFilesError}`);
        }

        // parsed filename
        const parsedDirName = dirname.replace('./', '');
        const parsedFileName = filename.replace(parsedDirName, '').replace(/^\//, '');
        const onlyFilename = filename.substr(filename.lastIndexOf('/') + 1);

        // add input sources to output
        if (filename.substr(filename.lastIndexOf('.') + 1) === 'sol'
          && filenameInclude(filename, exclude, include)
          && onlyFilename.charAt(0) !== '~'
          && onlyFilename.charAt(0) !== '#'
          && onlyFilename.charAt(0) !== '.') {
          sources[parsedFileName] = content;
        }

        // increase files readFiles
        filesRead += 1;

        // process next file
        if (filesRead === files.length) {
          // filter sources by focus dependencies
          if (focusContractPath) {
            callback(null, buildDependantsSourceTree(focusContractPath, sources));
          } else {
            callback(null, sources);
          }
        } else {
          next();
        }
      });
    }
  });
}
function getInputSources ( dirname , exclude , include , focusContractPath , callback ) { let filesRead = 0 ; const sources = { } ; // get all file names dir . files ( dirname , ( filesError , files ) => { if ( filesError ) { throwError ( ` ${ 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 ( dirname , ( readFilesError , content , filename , next ) => { if ( readFilesError ) { throwError ( ` ${ readFilesError } ` ) ; } // parsed filename const parsedDirName = dirname . replace ( './' , '' ) ; const parsedFileName = filename . replace ( parsedDirName , '' ) . replace ( / ^\/ / , '' ) ; const onlyFilename = filename . substr ( filename . lastIndexOf ( '/' ) + 1 ) ; // add input sources to output if ( filename . substr ( filename . lastIndexOf ( '.' ) + 1 ) === 'sol' && filenameInclude ( filename , exclude , include ) && onlyFilename . charAt ( 0 ) !== '~' && onlyFilename . charAt ( 0 ) !== '#' && onlyFilename . charAt ( 0 ) !== '.' ) { sources [ parsedFileName ] = content ; } // increase files readFiles filesRead += 1 ; // process next file if ( filesRead === files . length ) { // filter sources by focus dependencies if ( focusContractPath ) { callback ( null , buildDependantsSourceTree ( focusContractPath , sources ) ) ; } else { callback ( null , sources ) ; } } else { next ( ) ; } } ) ; } } ) ; }
get all contract input sources
get all contract input sources