mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Merge pull request #183 from tropperstyle/master
Adds support for scoped packages to the marko-taglib.json scanner
This commit is contained in:
commit
be298e867d
@ -88,6 +88,15 @@ function tryNodeModules(parent, helper) {
|
||||
if ((nodeModulesDir = realpathCached(nodeModulesDir))) {
|
||||
taglibsForNodeModulesDir = [];
|
||||
var children = fs.readdirSync(nodeModulesDir);
|
||||
// Add support for npm scoped packages
|
||||
children.forEach(function(scope, index, arr) {
|
||||
if (/^\@\w+$/.test(scope)) {
|
||||
var scoped = fs.readdirSync(nodePath.join(nodeModulesDir, scope));
|
||||
var splice = [index, 1];
|
||||
scoped.forEach(function(s) { splice.push(scope + '/' + s) });
|
||||
Array.prototype.splice.apply(arr, splice);
|
||||
}
|
||||
});
|
||||
children.forEach(function(moduleDirBasename) {
|
||||
// Fixes https://github.com/marko-js/marko/issues/140
|
||||
// If the same node_module is found multiple times then only load the first one.
|
||||
@ -182,4 +191,4 @@ exports.clearCaches = function() {
|
||||
existsCache = {};
|
||||
findCache = {};
|
||||
taglibsForNodeModulesDirCache = {};
|
||||
};
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user