Commit c5de95b8 authored by David Sveningsson's avatar David Sveningsson

fix(meta): load metadata with `readFile` instead of `require`

Friendlier to webpack.
parent c9ecd9d5
Pipeline #107327539 passed with stages
in 8 minutes and 47 seconds
import Ajv from "ajv";
import deepmerge from "deepmerge";
import fs from "fs";
import jsonMergePatch from "json-merge-patch";
import { HtmlElement } from "../dom";
import { SchemaValidationError, UserError } from "../error";
......@@ -101,7 +102,8 @@ export class MetaTable {
public loadFromFile(filename: string): void {
let json;
try {
json = require(filename);
const data = fs.readFileSync(filename, "utf-8");
json = JSON.parse(data);
} catch (err) {
throw new UserError(
`Failed to load element metadata from "${filename}"`,
......
import path from "path";
import { Config, Severity } from "./config";
import { Location } from "./context";
import { HtmlElement } from "./dom";
......@@ -27,7 +28,7 @@ describe("rule base class", () => {
reporter = new Reporter();
reporter.add = jest.fn();
meta = new MetaTable();
meta.loadFromFile("../../elements/html5.json");
meta.loadFromFile(path.join(__dirname, "../elements/html5.json"));
rule = new MockRule({});
rule.name = "mock-rule";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment