in modules/express-engine/schematics/utils/utils.ts [55:82]
export function findImport(
sourceFile: ts.SourceFile,
moduleName: string,
symbolName: string,
): ts.NamedImports | null {
// Only look through the top-level imports.
for (const node of sourceFile.statements) {
if (
!ts.isImportDeclaration(node) ||
!ts.isStringLiteral(node.moduleSpecifier) ||
node.moduleSpecifier.text !== moduleName
) {
continue;
}
const namedBindings = node.importClause && node.importClause.namedBindings;
if (!namedBindings || !ts.isNamedImports(namedBindings)) {
continue;
}
if (namedBindings.elements.some((element) => element.name.text === symbolName)) {
return namedBindings;
}
}
return null;
}