All files / if-run/lib exhaust.ts

100% Statements 13/13
100% Branches 4/4
100% Functions 1/1
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37      2x 2x   2x         2x           2x         8x   8x 3x     8x 3x     5x   5x    
/**
 * @todo This is temporary solution, will be refactored to support dynamic plugins.
 */
import {ExportLog} from '../builtins/export-log';
import {ExportYaml} from '../builtins/export-yaml';
 
import {STRINGS} from '../config';
 
import {Options} from '../types/process-args';
import {Context} from '../../common/types/manifest';
 
const {PREPARING_OUTPUT_DATA} = STRINGS;
 
/**
 * Output manager - Exhaust.
 * Grabs output plugins from context, executes every.
 */
export const exhaust = async (
  tree: any,
  context: Context,
  outputOptions: Options
) => {
  console.debug(PREPARING_OUTPUT_DATA(), '\n');
 
  if (!outputOptions.noOutput && !outputOptions.outputPath) {
    ExportLog().execute(tree, context);
  }
 
  if (!outputOptions.outputPath) {
    return;
  }
 
  const exportYaml = ExportYaml();
 
  await exportYaml.execute(tree, context, outputOptions.outputPath);
};