lib/ModuleFinder.js
function expandFiles(files, workingDirectory) {
  const promises = [];
  files.forEach((file) => {
    if (
      file.path !== './package.json' && file.path !== './npm-shrinkwrap.json'
    ) {
      promises.push(Promise.resolve(file));
      return;
    }
    findPackageDependencies(workingDirectory, true).forEach((dep) => {
      let resolvedPath;
      try {
        resolvedPath = forwardSlashes(path.relative(
          workingDirectory,
          requireRelative.resolve(dep, workingDirectory),
        ));
        if (!resolvedPath.startsWith('.')) {
          // path.relative won't add "./", but we need it further down the line
          resolvedPath = `./${resolvedPath}`;
        }
      } catch (e) {
        winston.error(`Failed to resolve "${dep}" relative to ${workingDirectory}`);
        return;
      }

      promises.push(lastUpdate.failSafe(resolvedPath, workingDirectory)
        .then(({ mtime }) =>
          Promise.resolve({
            path: resolvedPath,
            mtime,
            packageName: dep,
          })));
    });
  });
  return Promise.all(promises);
}
function expandFiles(files, workingDirectory) {
  const promises = [];
  files.forEach((file) => {
    if (
      file.path !== './package.json' && file.path !== './npm-shrinkwrap.json'
    ) {
      promises.push(Promise.resolve(file));
      return;
    }
    findPackageDependencies(workingDirectory, true).forEach((dep) => {
      let resolvedPath;
      try {
        resolvedPath = forwardSlashes(path.relative(
          workingDirectory,
          requireRelative.resolve(dep, workingDirectory),
        ));
        if (!resolvedPath.startsWith('.')) {
          // path.relative won't add "./", but we need it further down the line
          resolvedPath = `./${resolvedPath}`;
        }
      } catch (e) {
        winston.error(`Failed to resolve "${dep}" relative to ${workingDirectory}`);
        return;
      }

      promises.push(lastUpdate.failSafe(resolvedPath, workingDirectory)
        .then(({ mtime }) =>
          Promise.resolve({
            path: resolvedPath,
            mtime,
            packageName: dep,
          })));
    });
  });
  return Promise.all(promises);
}
function expandFiles ( files , workingDirectory ) { const promises = [ ] ; files . forEach ( ( file ) => { if ( file . path !== './package.json' && file . path !== './npm-shrinkwrap.json' ) { promises . push ( Promise . resolve ( file ) ) ; return ; } findPackageDependencies ( workingDirectory , true ) . forEach ( ( dep ) => { let resolvedPath ; try { resolvedPath = forwardSlashes ( path . relative ( workingDirectory , requireRelative . resolve ( dep , workingDirectory ) , ) ) ; if ( ! resolvedPath . startsWith ( '.' ) ) { // path.relative won't add "./", but we need it further down the line resolvedPath = ` ${ resolvedPath } ` ; } } catch ( e ) { winston . error ( ` ${ dep } ${ workingDirectory } ` ) ; return ; } promises . push ( lastUpdate . failSafe ( resolvedPath , workingDirectory ) . then ( ( { mtime } ) => Promise . resolve ( { path : resolvedPath , mtime , packageName : dep , } ) ) ) ; } ) ; } ) ; return Promise . all ( promises ) ; }
Checks for package.json or npm-shrinkwrap.json inside a list of files and
expands the list of files to include package dependencies if so.
Checks for package . json or npm - shrinkwrap . json inside a list of files and expands the list of files to include package dependencies if so .