Skip to content

Commit

Permalink
improve check
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdiguarana committed Nov 21, 2024
1 parent b1a4562 commit 167c07b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/schemas.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const schemaVersionsLoaded = {};
var schemas = {};
var schemasByVersion = {};
var dir = require('node-dir');
Expand All @@ -8,7 +9,6 @@ var _ = require('lodash');

var baseDir = path.join(path.dirname(module.filename), '../src/main/resources/schema/ans');

var callback = undefined;
var loaded = false;


Expand All @@ -19,7 +19,7 @@ var loadSchema = function loadSchema(version, done) {
return;
}

if (_.isObject(schemasByVersion[version])) {
if (schemasByVersion[version] && schemaVersionsLoaded[version]) {
done(null, schemasByVersion[version]);
return;
}
Expand All @@ -34,6 +34,7 @@ var loadSchema = function loadSchema(version, done) {
if (err) throw err;
if (!schemasByVersion[version]) {
schemasByVersion[version] = {};
schemaVersionsLoaded[version] = false;
}
var name = path.relative(schemaDir, filename);
try {
Expand All @@ -52,7 +53,7 @@ var loadSchema = function loadSchema(version, done) {
return;
}
}
loaded = true;
schemaVersionsLoaded[version] = true;
if (typeof done == 'function') {
done(null, schemasByVersion[version]);
return;
Expand Down

0 comments on commit 167c07b

Please sign in to comment.