MCPcopy Create free account
hub / github.com/angular/components / addModuleImportToModule

Function addModuleImportToModule

src/cdk/schematics/utils/ast.ts:46–68  ·  view source on GitHub ↗
(
  host: Tree,
  modulePath: string,
  moduleName: string,
  src: string,
)

Source from the content-addressed store, hash-verified

44 * @param src src location to import
45 */
46export function addModuleImportToModule(
47 host: Tree,
48 modulePath: string,
49 moduleName: string,
50 src: string,
51) {
52 const moduleSource = parseSourceFile(host, modulePath);
53
54 if (!moduleSource) {
55 throw new SchematicsException(`Module not found: ${modulePath}`);
56 }
57
58 const changes = addImportToModule(moduleSource, modulePath, moduleName, src);
59 const recorder = host.beginUpdate(modulePath);
60
61 changes.forEach(change => {
62 if (change instanceof InsertChange) {
63 recorder.insertLeft(change.pos, change.toAdd);
64 }
65 });
66
67 host.commitUpdate(recorder);
68}
69
70/** Wraps the internal find module from options with undefined path handling */
71export async function findModuleFromOptions(

Callers 7

addFormModulesToModuleFunction · 0.90
addTableModulesToModuleFunction · 0.90
addNavModulesToModuleFunction · 0.90
addNavModulesToModuleFunction · 0.90
addTreeModulesToModuleFunction · 0.90

Calls 2

parseSourceFileFunction · 0.85
insertLeftMethod · 0.80

Tested by

no test coverage detected