node-dependency-injection 3.0.0-alpha.6 → 3.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -215,7 +215,9 @@ var Autowire = /*#__PURE__*/function () {
215
215
 
216
216
  var parentId = this._getIdentifierFromImports(typeParent, body, parsedFile);
217
217
 
218
- definition.parent = parentId;
218
+ if (parentId) {
219
+ definition.parent = parentId;
220
+ }
219
221
  }
220
222
 
221
223
  if (constructorDeclaration) {
@@ -231,7 +233,9 @@ var Autowire = /*#__PURE__*/function () {
231
233
 
232
234
  var argumentId = this._getIdentifierFromImports(typeNameForArgument, body, parsedFile);
233
235
 
234
- definition.addArgument(new _Reference["default"](argumentId), definition["abstract"]);
236
+ if (argumentId) {
237
+ definition.addArgument(new _Reference["default"](argumentId), definition["abstract"]);
238
+ }
235
239
  } catch (e) {}
236
240
  }
237
241
  } catch (err) {
@@ -257,7 +261,7 @@ var Autowire = /*#__PURE__*/function () {
257
261
 
258
262
  var aliasId = this._getIdentifierFromImports(interfaceType, body, parsedFile);
259
263
 
260
- if (this.container.hasAlias(aliasId) === false) {
264
+ if (aliasId && this.container.hasAlias(aliasId) === false) {
261
265
  this.container.setAlias(aliasId, serviceId);
262
266
  }
263
267
  }
@@ -271,36 +275,40 @@ var Autowire = /*#__PURE__*/function () {
271
275
  }, {
272
276
  key: "_getIdentifierFromImports",
273
277
  value: function _getIdentifierFromImports(type, body, parsedFile) {
274
- var rootDir = parsedFile.dir;
275
- var relativeImportForImplement = body.find(function (declaration) {
276
- if (declaration.specifiers) {
277
- return declaration.specifiers.find(function (specifier) {
278
- return specifier.local.name === type;
279
- });
280
- }
278
+ try {
279
+ var rootDir = parsedFile.dir;
280
+ var relativeImportForImplement = body.find(function (declaration) {
281
+ if (declaration.specifiers) {
282
+ return declaration.specifiers.find(function (specifier) {
283
+ return specifier.local.name === type;
284
+ });
285
+ }
281
286
 
282
- return null;
283
- }).source.value;
287
+ return null;
288
+ }).source.value;
284
289
 
285
- if (this._tsConfigPaths) {
286
- for (var pathConfig in this._tsConfigPaths) {
287
- var tsConfigPath = pathConfig.replace(/\*/g, '');
288
- var tsRelativePath = this._tsConfigPaths[pathConfig][0];
289
- tsRelativePath = tsRelativePath.replace(/\*/g, '');
290
+ if (this._tsConfigPaths) {
291
+ for (var pathConfig in this._tsConfigPaths) {
292
+ var tsConfigPath = pathConfig.replace(/\*/g, '');
293
+ var tsRelativePath = this._tsConfigPaths[pathConfig][0];
294
+ tsRelativePath = tsRelativePath.replace(/\*/g, '');
290
295
 
291
- if (relativeImportForImplement.includes(tsConfigPath)) {
292
- relativeImportForImplement = relativeImportForImplement.replace(tsConfigPath, tsRelativePath);
296
+ if (relativeImportForImplement.includes(tsConfigPath)) {
297
+ relativeImportForImplement = relativeImportForImplement.replace(tsConfigPath, tsRelativePath);
293
298
 
294
- var parsedTsConfigPath = _path["default"].parse(this._tsConfigFullPath);
299
+ var parsedTsConfigPath = _path["default"].parse(this._tsConfigFullPath);
295
300
 
296
- rootDir = parsedTsConfigPath.dir;
301
+ rootDir = parsedTsConfigPath.dir;
302
+ }
297
303
  }
298
304
  }
299
- }
300
305
 
301
- var absolutePathImportForImplement = _path["default"].join(rootDir, relativeImportForImplement);
306
+ var absolutePathImportForImplement = _path["default"].join(rootDir, relativeImportForImplement);
302
307
 
303
- return this._getServiceIdFromPath(absolutePathImportForImplement, type);
308
+ return this._getServiceIdFromPath(absolutePathImportForImplement, type);
309
+ } catch (e) {
310
+ return null;
311
+ }
304
312
  }
305
313
  }]);
306
314
  return Autowire;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-dependency-injection",
3
- "version": "3.0.0-alpha.6",
3
+ "version": "3.0.0-alpha.7",
4
4
  "description": "The NodeDependencyInjection component allows you to standardize and centralize the way objects are constructed in your application.",
5
5
  "main": "dist/lib/index.js",
6
6
  "directories": {