Skip to content
Permalink
Browse files

Fix: Return right path when extending JSONs

  • Loading branch information...
molant committed Oct 19, 2019
1 parent de43df9 commit 0df8d196dc81432dc63172c1650c5a77971c209a
Showing with 6 additions and 7 deletions.
  1. +6 −7 packages/hint/src/lib/types/parser.ts
@@ -31,7 +31,7 @@ export abstract class Parser<E extends Events = Events> {
return config;
}

const configIncludes = new Set();
const configIncludes = [];

// `resource` has already been loaded to provide `config` so `getAsUri` won't be null.
let configPath = asPathString(getAsUri(resource)!);
@@ -42,7 +42,7 @@ export abstract class Parser<E extends Events = Events> {
* In case that we are running on Windows, we need
* to normalize the path to c:\path before continue.
*/
configIncludes.add(path.normalize(configPath));
configIncludes.push(path.normalize(configPath));

let finalConfigJSON: T = merge({}, config);

@@ -52,12 +52,12 @@ export abstract class Parser<E extends Events = Events> {

configPath = path.resolve(configDir, finalConfigJSON.extends);

if (configIncludes.has(configPath)) {
if (configIncludes.includes(configPath)) {

const error = new Error(`Circular reference found in file ${lastPath}`) as IParsingError;
const lastPathUri = getAsUri(lastPath);
const originalPathUri = getAsUri(configIncludes[0]);

error.resource = lastPathUri && lastPathUri.toString() || lastPath;
error.resource = originalPathUri && originalPathUri.toString() || lastPath;

return error;
}
@@ -67,8 +67,7 @@ export abstract class Parser<E extends Events = Events> {
try {
const extendedConfig = loadJSONFile(configPath);

console.log(`adding: ${configPath}`);
configIncludes.add(configPath);
configIncludes.push(configPath);

finalConfigJSON = merge({}, extendedConfig, finalConfigJSON);
} catch (err) {

0 comments on commit 0df8d19

Please sign in to comment.
You can’t perform that action at this time.