diff --git a/Nodejs/Product/Npm/SPI/NodeModules.cs b/Nodejs/Product/Npm/SPI/NodeModules.cs index ec36c0644..1f3d064d6 100644 --- a/Nodejs/Product/Npm/SPI/NodeModules.cs +++ b/Nodejs/Product/Npm/SPI/NodeModules.cs @@ -22,14 +22,19 @@ namespace Microsoft.NodejsTools.Npm.SPI { internal class NodeModules : AbstractNodeModules { - private Dictionary _allModules; private static readonly string[] _ignoredDirectories = { @"\.bin", @"\.staging" }; - public NodeModules(IRootPackage parent, bool showMissingDevOptionalSubPackages, Dictionary allModulesToDepth = null, int depth = 0) { - var modulesBase = Path.Combine(parent.Path, NodejsConstants.NodeModulesFolder); + private readonly Dictionary _allModules; + public NodeModules(IRootPackage parent, bool showMissingDevOptionalSubPackages, Dictionary allModulesToDepth = null, int depth = 0, int maxDepth = 1) { _allModules = allModulesToDepth ?? new Dictionary(); + if (depth >= maxDepth) { + return; + } + + var modulesBase = Path.Combine(parent.Path, NodejsConstants.NodeModulesFolder); + // This is the first time NodeModules is being created. // Iterate through directories to add everything that's known to be top-level. if (depth == 0) { diff --git a/Nodejs/Product/Npm/SPI/RootPackage.cs b/Nodejs/Product/Npm/SPI/RootPackage.cs index cd89507b1..7e1aadfa4 100644 --- a/Nodejs/Product/Npm/SPI/RootPackage.cs +++ b/Nodejs/Product/Npm/SPI/RootPackage.cs @@ -25,7 +25,8 @@ public RootPackage( string fullPathToRootDirectory, bool showMissingDevOptionalSubPackages, Dictionary allModules = null, - int depth = 0) { + int depth = 0, + int maxDepth = 1) { Path = fullPathToRootDirectory; var packageJsonFile = System.IO.Path.Combine(fullPathToRootDirectory, "package.json"); try { @@ -45,7 +46,7 @@ public RootPackage( } try { - Modules = new NodeModules(this, showMissingDevOptionalSubPackages, allModules, depth); + Modules = new NodeModules(this, showMissingDevOptionalSubPackages, allModules, depth, maxDepth); } catch (PathTooLongException) { // otherwise we fail to create it completely... }