index.js
function getElmPackageSourceDirectories(baseDir, currentDir) {
  if (typeof currentDir === "undefined") {
    baseDir = path.resolve(baseDir);
    currentDir = baseDir;
  }

  var elmPackagePath = path.join(currentDir, 'elm.json');
  if (fs.existsSync(elmPackagePath)) {
    var sourceDirectories = getSourceDirectories(elmPackagePath);
    if (_.includes(sourceDirectories, baseDir)) {
      return sourceDirectories;
    }
  }

  if (isRoot(currentDir)) {
    return [];
  }

  return getElmPackageSourceDirectories(baseDir, path.dirname(currentDir));
}
function getElmPackageSourceDirectories(baseDir, currentDir) {
  if (typeof currentDir === "undefined") {
    baseDir = path.resolve(baseDir);
    currentDir = baseDir;
  }

  var elmPackagePath = path.join(currentDir, 'elm.json');
  if (fs.existsSync(elmPackagePath)) {
    var sourceDirectories = getSourceDirectories(elmPackagePath);
    if (_.includes(sourceDirectories, baseDir)) {
      return sourceDirectories;
    }
  }

  if (isRoot(currentDir)) {
    return [];
  }

  return getElmPackageSourceDirectories(baseDir, path.dirname(currentDir));
}
Given a source directory (containing top-level Elm modules), locate the elm.json file that includes it and get all its source directories.