feat: bundle document before gathering stats (#227)

* feat: bundle document before gathering stats
* exitWithError moved to utils
This commit is contained in:
Andriy Leliv
2020-11-26 10:26:38 +02:00
committed by GitHub
parent 199855fd80
commit 258820349b
9 changed files with 87 additions and 52 deletions

View File

@@ -4,7 +4,7 @@ import * as yaml from 'js-yaml';
import * as path from 'path';
import { performance } from 'perf_hooks';
const isEqual = require('lodash.isequal');
import { printExecutionTime, pathToFilename, readYaml, writeYaml } from '../../utils';
import { printExecutionTime, pathToFilename, readYaml, writeYaml, exitWithError } from '../../utils';
import { isString, isObject, isEmptyObject } from '../../js-utils';
import {
Definition,
@@ -69,11 +69,6 @@ function isNotYaml(filename: string) {
return !(filename.endsWith('.yaml') || filename.endsWith('.yml'));
}
function exitWithError(message: string) {
process.stderr.write(red(message));
process.exit(1);
}
function loadFile(fileName: string) {
try {
return yaml.safeLoad(fs.readFileSync(fileName, 'utf8')) as Definition;