message: only follow devDeps at top level
diff: @@ -19,7 +19,7 @@ function loadPackages() {
  return result;
  }
  -function deps(pkg: PackageJSON) {
  +function deps(pkg: PackageJSON, includeDev: boolean) {
  let result: Set<string> = new Set();
  if (pkg.dependencies) {
  @@ -27,11 +27,13 @@ function deps(pkg: PackageJSON) {
  result.add(dep);
  }
  }
  + if (includeDev) {
  if (pkg.devDependencies) {
  for (let dep of Object.keys(pkg.devDependencies)) {
  result.add(dep);
  }
  }
  + }
  return result;
  }
  @@ -45,19 +47,28 @@ export default function findDependencies(startPackage: string) {
  }
  let used: Set<PackageJSON> = new Set();
  - crawl(pkg, packages, used);
  + crawl(pkg, packages, used, 0);
  return [...used].map(p => p.name);
  }
  -function crawl(pkg: PackageJSON, packages: Map<string, PackageJSON>, used: Set<PackageJSON>) {
  +function crawl(
  + pkg: PackageJSON,
  + packages: Map<string, PackageJSON>,
  + used: Set<PackageJSON>,
  + depth: number
  +) {
  if (used.has(pkg)) {
  return;
  }
  used.add(pkg);
  - for (let dep of deps(pkg)) {
  + for (let dep of deps(pkg, depth === 0)) {
  let depPkg = packages.get(dep);
  if (depPkg) {
  - crawl(depPkg, packages, used);
  + crawl(depPkg, packages, used, depth + 1);
  + }
  }
  }
  +
  +if (require.main === module) {
  + process.stdout.write(findDependencies(process.argv[2]).sort().join("\n"));
  }
  