Skip to content

Commit

Permalink
fix #6 when build-decision fails, build continues (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrezero authored Jan 21, 2025
1 parent e1b4602 commit 5cf4f2b
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions docs/designer-decisions/scripts/build-decisions.mjs
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
import path from 'path';

import { SAMPLE_DATA } from '@noodlestan/designer-decisions';
import {
createDecisionLoader,
formatDecision,
formatStoreError,
formatValidationError,
getDecisionStatus,
createDecisionLoader,
} from '@noodlestan/designer-functions';
import path from 'path';

import { SAMPLE_DATA } from '@noodlestan/designer-decisions';
import { DECISION_SCHEMAS } from '@noodlestan/designer-schemas';

const DATA_PATH = path.resolve('./data/decisions');

const loader = createDecisionLoader(
const decisionLoader = createDecisionLoader(
[DECISION_SCHEMAS],
[SAMPLE_DATA, DATA_PATH],
async moduleName => `../../node_modules/${moduleName}`,
);

const loadDecisions = async () => {
const store = await loader();
const load = async () => {
const store = await decisionLoader();
if (store.hasErrors()) {
store.storeErrors().forEach(({ msg, error }) => console.error(msg, error));
store.validationErrors().forEach(error => console.error(formatValidationError(error)));
store.storeErrors()?.forEach(error => console.error(formatStoreError(error)));
store.validationErrors()?.forEach(error => console.error(formatValidationError(error)));
}
const records = store.records();
const records = store.records().length;
const errors = store.storeErrors().length;
const validationErrors = store.validationErrors().length;
console.info(`🐘 ${records.length} records, ${errors} errors, ${validationErrors} warnings`);

records.forEach(record => {
const status = getDecisionStatus(store, record);
console.info(formatDecision(status));
});
console.info(`🐘 ${records} records, ${errors} errors, ${validationErrors} warnings`);
if (store.hasErrors()) {
throw new Error();
}
};

loadDecisions();
load().catch(() => process.exit(1));

0 comments on commit 5cf4f2b

Please sign in to comment.