dependency-injection-cat
Advanced tools
Comparing version 0.0.11 to 0.0.12
{ | ||
"name": "dependency-injection-cat", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "types": "index.d.ts", |
@@ -16,2 +16,3 @@ "use strict"; | ||
var ExportDeclarationWithoutClauseAndModuleSpecifier_1 = require("./ExportDeclarationWithoutClauseAndModuleSpecifier"); | ||
var ExternalExportDeclaration_1 = require("./ExternalExportDeclaration"); | ||
//TODO Add support for default imports/exports | ||
@@ -95,2 +96,37 @@ function getNodeSourceDescriptorDeep(sourceFile, nameToFind) { | ||
} | ||
//Trying to find node in external exports | ||
var externalExports = exportDeclarations.filter(ExternalExportDeclaration_1.isExternalExportDeclaration); | ||
var externalNamespaceExport = externalExports.find(function (it) { | ||
if (ts.isNamespaceExport(it.exportClause)) { | ||
return it.exportClause.name.getText() === splittedNameToFind[0]; | ||
} | ||
return false; | ||
}); | ||
if (externalNamespaceExport !== undefined) { | ||
var modulePath = removeQuotesFromString_1.removeQuotesFromString(externalNamespaceExport.moduleSpecifier.getText()); | ||
var resolvedPath = PathResolverCache_1.PathResolverCache.getAbsolutePathWithExtension(sourceFile.fileName, modulePath); | ||
if (!path_1.default.isAbsolute(resolvedPath)) { | ||
throw new Error("\n DI container does not support export * as Something from 'node-module'\n " + externalNamespaceExport.getText() + "\n in " + sourceFile.fileName + "\n "); | ||
} | ||
var newSourceFile = SourceFilesCache_1.SourceFilesCache.getSourceFileByPath(resolvedPath); | ||
return getNodeSourceDescriptorDeep(newSourceFile, splittedNameToFind[1]); | ||
} | ||
var externalNamedExports = externalExports.filter(ExternalExportDeclaration_1.isNamedExternalExportsDeclaration); | ||
var externalExportClauseElements = lodash_1.flatten(externalNamedExports.map(function (it) { return it.exportClause.elements; })); | ||
var externalExportSpecifier = externalExportClauseElements.find(function (it) { return it.name.getText() === splittedNameToFind[0]; }); | ||
if (externalExportSpecifier !== undefined) { | ||
var externalExportNameToFind = externalExportSpecifier.propertyName | ||
? tslib_1.__spreadArrays([ | ||
externalExportSpecifier.propertyName.getText() | ||
], splittedNameToFind.slice(1)).join('.') | ||
: splittedNameToFind.join('.'); | ||
var exportExpression = externalExportSpecifier.parent.parent; | ||
var modulePath = removeQuotesFromString_1.removeQuotesFromString(exportExpression.moduleSpecifier.getText()); | ||
var resolvedPath = PathResolverCache_1.PathResolverCache.getAbsolutePathWithExtension(sourceFile.fileName, modulePath); | ||
if (!path_1.default.isAbsolute(resolvedPath)) { | ||
throw new Error("\n DI container does not support export * as Something from 'node-module'\n " + exportExpression.getText() + "\n in " + sourceFile.fileName + "\n "); | ||
} | ||
var newSourceFile = SourceFilesCache_1.SourceFilesCache.getSourceFileByPath(resolvedPath); | ||
return getNodeSourceDescriptorDeep(newSourceFile, externalExportNameToFind); | ||
} | ||
//Trying to find in export * from '' declarations | ||
@@ -103,3 +139,3 @@ var exportAllStatements = exportDeclarations.filter(ExportDeclarationWithoutClauseAndModuleSpecifier_1.isExportDeclarationWithoutClauseAndWithModuleSpecifier); | ||
if (!path_1.default.isAbsolute(resolvedPath)) { | ||
throw new Error("\n DI container does not support \"export * from 'node-module'\n " + it.getText() + "\n in " + sourceFile.fileName + "\n "); | ||
throw new Error("\n DI container does not support export * from 'node-module'\n " + it.getText() + "\n in " + sourceFile.fileName + "\n "); | ||
} | ||
@@ -106,0 +142,0 @@ var newSourceFile = SourceFilesCache_1.SourceFilesCache.getSourceFileByPath(resolvedPath); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
142212
206
2590