jondot / hygen

The simple, fast, and scalable code generator that lives in your project.
http://www.hygen.io
MIT License
5.65k stars 253 forks source link

Re-apply fix for chalk template #411

Open ben-eb opened 1 year ago

ben-eb commented 1 year ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

https://github.com/jondot/hygen/pull/335 introduced a fix for chalk.template that I think was overwritten in error by https://github.com/jondot/hygen/commit/6c43f266dbaf2e82f7b3c23a732025cd8b349031. Applying the below patch will restore the template support but a better solution would be to modify the TypeScript source code so future regressions are prevented.

Today I used patch-package to patch hygen@6.2.11 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/hygen/dist/logger.js b/node_modules/hygen/dist/logger.js
index 312f112..036c45d 100644
--- a/node_modules/hygen/dist/logger.js
+++ b/node_modules/hygen/dist/logger.js
@@ -5,7 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
 Object.defineProperty(exports, "__esModule", { value: true });
 const chalk_1 = __importDefault(require("chalk"));
 // chalk 4.1.2 doesn't type template property
-const { yellow, red, green, magenta, template } = chalk_1.default;
+const { yellow, red, green, magenta } = chalk_1.default;
+const template = require('chalk/source/templates');
 class Logger {
     constructor(log) {
         this.log = log;

This issue body was partially generated by patch-package.