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 38 39 | 1x 1x 1x 1x 1x 1x 1x 3x 3x 1x 2x 2x 2x 2x 2x | import * as YAML from 'js-yaml';
import {ERRORS} from '@grnsft/if-core/utils';
import {openYamlFileAsObject} from '../../common/util/yaml';
import {STRINGS} from '../config';
import {LoadDiffParams} from '../types/args';
import {Manifest} from '../../common/types/manifest';
const {CliSourceFileError} = ERRORS;
const {INVALID_SOURCE} = STRINGS;
/**
* Loads files to compare. As a source file checks if data is piped and then decides which one to take.
*/
export const loadIfDiffFiles = async (params: LoadDiffParams) => {
const {sourcePath, targetPath, pipedSourceManifest} = params;
if (!sourcePath && !pipedSourceManifest) {
throw new CliSourceFileError(INVALID_SOURCE);
}
const loadFromSource =
sourcePath && (await openYamlFileAsObject<Manifest>(sourcePath!));
const loadFromSTDIN =
pipedSourceManifest && (await YAML.load(pipedSourceManifest!));
const rawSourceManifest = loadFromSource || loadFromSTDIN;
const rawTargetManifest = await openYamlFileAsObject<Manifest>(targetPath);
return {
rawSourceManifest,
rawTargetManifest,
};
};
|