Skip to content

Commit

Permalink
Editing local.json file need not break app
Browse files Browse the repository at this point in the history
  • Loading branch information
peterMuriuki committed Jan 23, 2023
1 parent 7947d40 commit efaae2e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 12 additions & 12 deletions apps/web/src/lib/server/appConfig/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import { basename } from 'node:path';
import { allSymbolConfigsAccessor } from '$lib/server/constants';

export const getConfig = (key: string, defualt?: unknown, getFromDefaultToo = true) => {
const config: IConfig = importFresh('config');
try {
const config: IConfig = importFresh('config');

const sources = config.util.getConfigSources();
const localSource = sources.filter((source) => basename(source.name) === 'local.json')[0];
const sources = config.util.getConfigSources();
const localSource = sources.filter((source) => basename(source.name) === 'local.json')[0];

// if only default then return default
if (!getFromDefaultToo) {
if (localSource?.parsed[allSymbolConfigsAccessor] === undefined) {
if (defualt !== undefined) {
return defualt;
} else {
throw new Error(`${key} was not found in the ${localSource.name}`);
// if only default then return default
if (!getFromDefaultToo) {
if (localSource?.parsed[allSymbolConfigsAccessor] === undefined) {
if (defualt !== undefined) {
return defualt;
} else {
throw new Error(`${key} was not found in the ${localSource.name}`);
}
}
}
}
try {
const value = config.get(key);
return value;
} catch (err) {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/evaluator/pipelinesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ export class PipelinesController {
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
for (const [uuid, _] of Object.entries(existingPipelinesCounter)) {
this.stopScheduledEvaluations(uuid);
delete this.pipelines[uuid];
delete this.tasks[uuid];
}
}

Expand Down

0 comments on commit efaae2e

Please sign in to comment.