@tsed/di 6.84.1 → 6.86.2

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.
package/lib/index.d.ts CHANGED
@@ -14,3 +14,4 @@ export * from "./utils/createContainer";
14
14
  export * from "./utils/getConfiguration";
15
15
  export * from "./utils/getConfiguration";
16
16
  export * from "./utils/setLoggerLevel";
17
+ export * from "./utils/colors";
package/lib/index.js CHANGED
@@ -1410,9 +1410,18 @@ function Controller(options) {
1410
1410
  }, path && schema.Path(path), schema.Children(...children));
1411
1411
  }
1412
1412
 
1413
+ // istanbul ignore next
1413
1414
  const colorIfAllowed = colorFn => text => !process.env.NO_COLOR ? colorFn(text) : text;
1414
1415
 
1415
1416
  const red = colorIfAllowed(text => `\x1B[31m${text}\x1B[39m`);
1417
+ const yellow = colorIfAllowed(text => `\x1B[33m${text}\x1B[39m`);
1418
+ const green = colorIfAllowed(text => `\x1B[32m${text}\x1B[39m`);
1419
+ const colors = {
1420
+ red,
1421
+ yellow,
1422
+ green
1423
+ };
1424
+
1416
1425
  class InjectionError extends Error {
1417
1426
  constructor(token, origin) {
1418
1427
  super(core.isString(origin) ? origin : "");
@@ -1459,7 +1468,7 @@ function printDependencyInjectionError(token, options) {
1459
1468
  const args = core.getConstructorArgNames(token).map((arg, index) => {
1460
1469
  if (options.index === index) {
1461
1470
  erroredArg = arg;
1462
- arg = red(arg);
1471
+ arg = colors.red(arg);
1463
1472
  }
1464
1473
 
1465
1474
  return `${arg}: ${core.nameOf(options.deps[index])}`;
@@ -1467,7 +1476,7 @@ function printDependencyInjectionError(token, options) {
1467
1476
  const signature = core.nameOf(token) + "->constructor(" + args + ")";
1468
1477
  const indexOf = signature.indexOf(erroredArg) - 5;
1469
1478
 
1470
- const drawline = indexOf => " ".repeat(indexOf) + red("^" + "‾".repeat(erroredArg.length - 1));
1479
+ const drawline = indexOf => " ".repeat(indexOf) + colors.red("^" + "‾".repeat(erroredArg.length - 1));
1471
1480
 
1472
1481
  return "Unable to inject dependency. " + options.message + "\n\n" + signature + "\n" + (indexOf > -1 ? drawline(indexOf) : "");
1473
1482
  }
@@ -2463,6 +2472,7 @@ exports.Service = Service;
2463
2472
  exports.UndefinedTokenError = UndefinedTokenError;
2464
2473
  exports.UseOpts = UseOpts;
2465
2474
  exports.Value = Value;
2475
+ exports.colors = colors;
2466
2476
  exports.createContainer = createContainer;
2467
2477
  exports.getConfiguration = getConfiguration;
2468
2478
  exports.injectProperty = injectProperty;