From fe3730d1a25976c4859f78d0d08642c90a83d860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?W=C3=A9sley=20Guimar=C3=A3es?= Date: Sun, 3 Dec 2023 01:02:39 -0300 Subject: [PATCH 1/4] feat: add support for .hygen.cjs file lookup This together with #434 should help fix some commonjs problems --- src/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index 5d5fbc8..bce58fb 100644 --- a/src/config.ts +++ b/src/config.ts @@ -14,7 +14,7 @@ const reversePathsToWalk = ({ folder, path }) => { } const configLookup = (file: string, folder: string, path: any = importedPath) => - uniq(reversePathsToWalk({ folder, path }).map((p) => path.join(p, file))) + uniq(reversePathsToWalk({ folder, path }).map((p) => [path.join(p, file), path.join(p, file).replace(/.js$/, '.cjs')]).flat()) class ConfigResolver { configFile: string From bd08a42aac195a8ccf363524dcfde41805d39c1f Mon Sep 17 00:00:00 2001 From: Dan Turner Date: Fri, 1 Sep 2023 16:05:19 +1000 Subject: [PATCH 2/4] fix: add index.cjs to list of potential config files to support module type packages Closes: https://github.com/jondot/hygen/issues/433 --- src/prompt.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/prompt.ts b/src/prompt.ts index ea70239..f653e28 100644 --- a/src/prompt.ts +++ b/src/prompt.ts @@ -4,6 +4,7 @@ import type { Prompter } from './types' import helpers from './helpers' const hooksfiles = [ + 'index.cjs', 'index.js', 'index.ts', 'prompt.cjs', From 608239feabe3d182611d414fd3a83c56a0ee0505 Mon Sep 17 00:00:00 2001 From: Saulo Vallory Date: Wed, 20 Mar 2024 00:53:13 -0300 Subject: [PATCH 3/4] Add support for mjs files too --- src/config.ts | 10 +++++++++- src/prompt.ts | 6 ++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/config.ts b/src/config.ts index bce58fb..d1015e1 100644 --- a/src/config.ts +++ b/src/config.ts @@ -14,7 +14,15 @@ const reversePathsToWalk = ({ folder, path }) => { } const configLookup = (file: string, folder: string, path: any = importedPath) => - uniq(reversePathsToWalk({ folder, path }).map((p) => [path.join(p, file), path.join(p, file).replace(/.js$/, '.cjs')]).flat()) + uniq( + reversePathsToWalk({ folder, path }) + .map((p) => [ + path.join(p, file), + path.join(p, file).replace(/.js$/, '.cjs'), + path.join(p, file).replace(/.js$/, '.mjs'), + ]) + .flat(), + ) class ConfigResolver { configFile: string diff --git a/src/prompt.ts b/src/prompt.ts index f653e28..806a723 100644 --- a/src/prompt.ts +++ b/src/prompt.ts @@ -4,11 +4,13 @@ import type { Prompter } from './types' import helpers from './helpers' const hooksfiles = [ - 'index.cjs', 'index.js', + 'index.cjs', + 'index.mjs', 'index.ts', - 'prompt.cjs', 'prompt.js', + 'prompt.cjs', + 'prompt.mjs', 'prompt.ts', ] const prompt = async ( From d637c067da4c4115c9d36d68a36459b465365dfd Mon Sep 17 00:00:00 2001 From: Saulo Vallory Date: Wed, 20 Mar 2024 01:39:06 -0300 Subject: [PATCH 4/4] Oops! fogot about mts and cts too --- src/prompt.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/prompt.ts b/src/prompt.ts index 806a723..fc2617d 100644 --- a/src/prompt.ts +++ b/src/prompt.ts @@ -8,10 +8,14 @@ const hooksfiles = [ 'index.cjs', 'index.mjs', 'index.ts', + 'index.cts', + 'index.mts', 'prompt.js', 'prompt.cjs', 'prompt.mjs', 'prompt.ts', + 'prompt.cts', + 'prompt.mts', ] const prompt = async ( createPrompter: () => Prompter,