Skip to content

Commit

Permalink
fix: esm dynamic import of enquirer
Browse files Browse the repository at this point in the history
fix #631
  • Loading branch information
cenk1cenk2 committed Sep 5, 2022
1 parent b55604e commit 55bed0a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
node-version:
- 16.x
- 18.x
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
5 changes: 4 additions & 1 deletion src/utils/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ export async function createPrompt (this: any, options: PromptOptions | PromptOp
enquirer = settings.enquirer
} else {
try {
enquirer = new (await import('enquirer')).default()
const imported = await import('enquirer')

// should fix the import problem for esm since there is no default imports there
enquirer = imported.default ? new imported.default() : new (imported as unknown as new () => Enquirer)()
} /* istanbul ignore next */ catch (e: any) {
this.task.prompt = new PromptError('Enquirer is a peer dependency that must be installed separately.')

Expand Down

0 comments on commit 55bed0a

Please sign in to comment.