code: function findFirstFile (name, rootDir) {
    return new Promise(function (resolve, reject) {
      var resultPath;
  
      function end() {
        if (resultPath) {
          resolve(resultPath);
        } else {
          reject(new Error(
            format('file is not found, name: \'%s\'', name)
          ));
        }
      }
  
      var finder = findit(rootDir)
      .on('file', function (path) {
        // We can receive here 'path': 'a/b/my-file', 'a/b/bad-my-file',
        //  'my-file', 'bad-my-file'.
        // Both 'a/b/my-file' and 'my-file' should be valid.
        if (path === name || endsWith(path, '/' + name)) {
          resultPath = path;
          finder.stop();
        }
      })
      .on('error', function (error) {
        reject(new Error(error));
      })
      .on('stop', end)
      .on('end', end);
    })
      .catch(function (error) {
        console.error(
          'finder failed, error: \'%s\', stack: \'%s\'',
          error.toString(), error.stack
        );
        return Promise.reject(error);
      });
  }
docs: We want to find the first path that ends with 'name'.