From b6ad06ad64d91b4722f3edeac4678da19afb7f82 Mon Sep 17 00:00:00 2001 From: Jonathan Tropper Date: Wed, 9 Dec 2015 15:57:37 -0800 Subject: [PATCH] Adds support for scoped packages to the marko-taglib.json scanner --- compiler/taglibs/taglib-finder.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/compiler/taglibs/taglib-finder.js b/compiler/taglibs/taglib-finder.js index 1f5ebe9441..5664704788 100644 --- a/compiler/taglibs/taglib-finder.js +++ b/compiler/taglibs/taglib-finder.js @@ -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 = {}; -}; \ No newline at end of file +};