code: function findRoot(root) {
    var pkg;
    root = root.split(path.sep);
    while(!pkg && root.length > 1) {
      var cur = root.join(path.sep);
      if(fs.existsSync(path.join(cur, "package.json"))) {
        return cur;
      }
      root.pop();
    }
  }
docs: Since our current development pattern uses npm as its package repository, we treat the nearest ancestor directory with a package.json (inclusive) as the directory's "root".