Use require.resolve as a fallback of path.resolve (#342)

This commit is contained in:
Alexander Kachkaev 2020-10-22 04:40:54 +01:00 committed by David Anson
parent bc0b7373ff
commit 4bff44e33f
9 changed files with 5672 additions and 8 deletions

View file

@ -1037,6 +1037,21 @@ tape("configMultiple", (test) => {
});
});
tape("configMultipleWithRequireResolve", (test) => {
test.plan(2);
markdownlint.readConfig("./test/config/config-packageparent.json",
function callback(err, actual) {
test.ifError(err);
const expected = {
...require("./node_modules/pseudo-package/config-frompackage.json"),
...require("./config/config-packageparent.json")
};
delete expected.extends;
test.deepEqual(actual, expected, "Config object not correct.");
test.end();
});
});
tape("configBadFile", (test) => {
test.plan(4);
markdownlint.readConfig("./test/config/config-badfile.json",
@ -1064,6 +1079,20 @@ tape("configBadChildFile", (test) => {
});
});
tape("configBadChildPackage", (test) => {
test.plan(4);
markdownlint.readConfig("./test/config/config-badchildpackage.json",
function callback(err, result) {
test.ok(err, "Did not get an error for bad child file.");
test.ok(err instanceof Error, "Error not instance of Error.");
// @ts-ignore
test.equal(err.code, "ENOENT",
"Error code for bad child file not ENOENT.");
test.ok(!result, "Got result for bad child file.");
test.end();
});
});
tape("configBadJson", (test) => {
test.plan(3);
markdownlint.readConfig("./test/config/config-badjson.json",