Skip to content
Permalink
Browse files

resolve path with context if passed

  • Loading branch information
1000ch committed Sep 16, 2015
1 parent 95e87e9 commit 901fabe26158f0ca1fae53d01a8a3695a4a1e68e
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/textlint-engine.js
@@ -75,13 +75,16 @@ TextLintEngine.prototype.setupRules = function (config) {
* if already rule is loaded, do not anything.
* @param {string} ruleName
*/
TextLintEngine.prototype.loadRule = function (ruleName) {
TextLintEngine.prototype.loadRule = function (ruleName, directory) {
// ignore already defined rule
// ignore rules from rulePaths because avoid ReferenceError is that try to require.
if (ruleManager.isDefinedRule(ruleName)) {
return;
}
var pkgPath = tryResolve("textlint-rule-" + ruleName) || tryResolve(ruleName);
if (!directory) {
directory = "";
}
var pkgPath = tryResolve(path.join(directory, "textlint-rule-" + ruleName)) || tryResolve(path.join(directory, ruleName));
if (!pkgPath) {
throw new ReferenceError(ruleName + " is not found");
}

0 comments on commit 901fabe

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