async function runCommand(options) {
  const rcFilePath = resolveRcFilePath(options.config);
  const rcFile = rcFilePath && loadRcFile(rcFilePath);
  const ciConfiguration = rcFile ? flattenRcToConfig(rcFile) : {};
  _.merge(ciConfiguration, _.pick(options, ['assert', 'collect', 'upload']));

  const defaultFlags = options.config ? [`--config=${options.config}`] : [];
  let hasFailure = false;

  const healthcheckStatus = runChildCommand('healthcheck', [...defaultFlags, '--fatal']).status;
  if (healthcheckStatus !== 0) process.exit(healthcheckStatus);

  const collectHasUrlOrBuildDir =
    ciConfiguration.collect &&
    (ciConfiguration.collect.url || ciConfiguration.collect.staticDistDir);
  const collectArgs = collectHasUrlOrBuildDir
    ? [getStartServerCommandFlag()]
    : [`--static-dist-dir=${findBuildDir()}`];
  const collectStatus = runChildCommand('collect', [...defaultFlags, ...collectArgs]).status;
  if (collectStatus !== 0) process.exit(collectStatus);

  // We'll run assertions if there's assert options OR they haven't configured anything to do with the results
  if (ciConfiguration.assert || (!ciConfiguration.assert && !ciConfiguration.upload)) {
    const assertArgs = ciConfiguration.assert ? [] : [`--preset=lighthouse:recommended`];
    const assertStatus = runChildCommand('assert', [...defaultFlags, ...assertArgs]).status;
    hasFailure = assertStatus !== 0;
  }

  // We'll run upload only if they've configured the upload command
  if (ciConfiguration.upload) {
    const uploadStatus = runChildCommand('upload', defaultFlags).status;
    if (options.failOnUploadFailure && uploadStatus !== 0) process.exit(uploadStatus);
    if (uploadStatus !== 0) process.stderr.write(`WARNING: upload command failed.\n`);
  }

  if (hasFailure) {
    process.stderr.write(`assert command failed. Exiting with status code 1.\n`);
    process.exit(1);
  }

  process.stdout.write(`Done running autorun.\n`);
}
@param {LHCI.AutorunCommand.Options} options
@return {Promise<void>}