async function saveFlowArtifacts(flowArtifacts, basePath) {
  const status = {msg: 'Saving flow artifacts', id: 'lh:assetSaver:saveArtifacts'};
  log.time(status);
  fs.mkdirSync(basePath, {recursive: true});

  // Delete any previous artifacts in this directory.
  const filenames = fs.readdirSync(basePath);
  for (const filename of filenames) {
    if (stepDirectoryRegex.test(filename) || filename === optionsFilename) {
      fs.rmSync(`${basePath}/${filename}`, {recursive: true});
    }
  }

  const {gatherSteps, ...flowOptions} = flowArtifacts;
  for (let i = 0; i < gatherSteps.length; ++i) {
    const {artifacts, ...stepOptions} = gatherSteps[i];
    const stepPath = path.join(basePath, `step${i}`);
    await saveArtifacts(artifacts, stepPath);
    fs.writeFileSync(
      path.join(stepPath, optionsFilename),
      JSON.stringify(stepOptions, stringifyReplacer, 2) + '\n'
    );
  }

  fs.writeFileSync(
    path.join(basePath, optionsFilename),
    JSON.stringify(flowOptions, stringifyReplacer, 2) + '\n'
  );

  log.log('Flow artifacts saved to disk in folder:', basePath);
  log.timeEnd(status);
}
Saves flow artifacts with the following file structure:
  flow/                             --  Directory specified by `basePath`.
    options.json                    --  Flow options (e.g. flow name, flags).
    step0/                          --  Directory containing artifacts for the first step.
      options.json                  --  First step's options (e.g. step flags).
      artifacts.json                --  First step's artifacts except the DevTools log and trace.
      defaultPass.devtoolslog.json  --  First step's DevTools log.
      defaultPass.trace.json        --  First step's trace.
    step1/                          --  Directory containing artifacts for the second step.

@param {LH.UserFlow.FlowArtifacts} flowArtifacts
@param {string} basePath
@return {Promise<void>}