Skip to content

Commit

Permalink
Merge pull request #1 from svallory/feature/allow-cjs-config
Browse files Browse the repository at this point in the history
Feature: allow cjs config closes jondot#434 and jondot#437
  • Loading branch information
svallory authored Mar 20, 2024
2 parents 26f76d8 + d637c06 commit d3e26df
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
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
Expand Down
9 changes: 8 additions & 1 deletion src/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ import helpers from './helpers'

const hooksfiles = [
'index.js',
'index.cjs',
'index.mjs',
'index.ts',
'prompt.cjs',
'index.cts',
'index.mts',
'prompt.js',
'prompt.cjs',
'prompt.mjs',
'prompt.ts',
'prompt.cts',
'prompt.mts',
]
const prompt = async <Q, T>(
createPrompter: () => Prompter<Q, T>,
Expand Down

0 comments on commit d3e26df

Please sign in to comment.