Skip to content

Commit e445030

Browse files
committed
Update to ensure plug-ins are used over files
This update ensures plug-ins (`remark-$foo`) are preferred over files or directories (`$foo`, `$foo.js`, `node_modules/$foo`, &c.) This became problematic for plug-ins like `remark-license`, as a file named `LICENSE` is often available. Or, for users with other similar named non-plugins. Closes GH-158. Closes GH-160.
1 parent 2065034 commit e445030

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

lib/cli/file-pipeline/configure.js

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,17 @@ function findRoot(base) {
7272
/**
7373
* Require a plugin. Checks, in this order:
7474
*
75+
* - `$package/node_modules/remark-$pathlike`;
76+
* - `$cwd/node_modules/remark-$pathlike`;
77+
* - `$modules/remark-$pathlike` (if global).
7578
* - `$package/$pathlike`;
7679
* - `$package/$pathlike.js`;
7780
* - `$package/node_modules/$pathlike`;
78-
* - `$package/node_modules/remark-$pathlike`;
7981
* - `$cwd/node_modules/$pathlike`;
80-
* - `$cwd/node_modules/remark-$pathlike`;
81-
* - `$pathlike`.
82+
* - `$modules/$pathlike` (if global);
8283
*
83-
* Where `$package` is an ancestral package directory.
84-
*
85-
* When using a globally installed executable, the
86-
* following are also included:
87-
*
88-
* - `$modules/$pathlike`;
89-
* - `$modules/remark-$pathlike`.
90-
*
91-
* Where `$modules` is the directory of globally installed
84+
* Where `$package` is an ancestral package directory,
85+
* and `$modules` is the directory of globally installed
9286
* npm packages.
9387
*
9488
* @see https://docs.npmjs.com/files/folders#node-modules
@@ -111,19 +105,23 @@ function findPlugin(pathlike, cwd) {
111105
var plugin = pathlike;
112106
var length;
113107
var paths = [
108+
resolve(root, MODULES, pluginlike),
109+
resolve(cwd, MODULES, pluginlike)
110+
];
111+
112+
if (isGlobal) {
113+
paths.push(resolve(globals, pluginlike));
114+
}
115+
116+
paths.push(
114117
resolve(root, pathlike),
115118
resolve(root, pathlike + '.js'),
116-
resolve(root, MODULES, pluginlike),
117119
resolve(root, MODULES, pathlike),
118-
resolve(cwd, MODULES, pluginlike),
119120
resolve(cwd, MODULES, pathlike)
120-
];
121+
);
121122

122123
if (isGlobal) {
123-
paths.push(
124-
resolve(globals, pathlike),
125-
resolve(globals, pluginlike)
126-
);
124+
paths.push(resolve(globals, pathlike));
127125
}
128126

129127
length = paths.length;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"jscs-jsdoc": "^1.0.0",
9191
"mocha": "^2.0.0",
9292
"remark-comment-config": "^3.0.0-alpha.1",
93+
"remark-license": "^2.0.0-alpha.1",
9394
"remark-github": "^4.0.1",
9495
"remark-html": "^3.0.0-alpha.2",
9596
"remark-lint": "^2.0.0",

0 commit comments

Comments
 (0)