public void AddReference(string resourcePath) { var module = moduleContainer.FindModuleContainingResource(resourcePath) ?? moduleContainer.FindModule(resourcePath.TrimEnd('/', '*')); if (module == null) { // The resourcePath may be an external URL. Uri url; if (Uri.TryCreate(resourcePath, UriKind.Absolute, out url)) { modules.Add(Module.CreateExternalModule(resourcePath, location: "")); } else { throw new ArgumentException("Resource not found: " + resourcePath); } } else { modules.Add(module); } }
public void FindModuleContainingScript_with_known_path_returns_the_Module() { var module = moduleContainer.FindModuleContainingResource(@"scripts/module-a/test.js"); module.Path.ShouldEqual(@"scripts/module-a"); }