Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected error when specifying a wildcarded path for linting on Windows #1521

Closed
dmitri-trofimov opened this issue Apr 10, 2024 · 0 comments
Labels
Type: Bug Something isn't working

Comments

@dmitri-trofimov
Copy link
Contributor

Describe the bug

When trying to run @redocly/cli lint and providing a wildcarded path on Windows the command exist with exit code 1 without any error text.

To Reproduce
Steps to reproduce the behavior:

  1. Make sure you are on Windows. I used v11, and Node 20, but it's also reproducible on Node v18. Haven't tried other Nodes.
  2. Create an empty Node.js project by running npm init in a directory of your choice
  3. Add @redocly/cli to your project by running npm install @redocly/cli
  4. Create a very simple project structure:
<ROOT>
├─ api
│  └─ providers
│     └─ test-provider
│        └─ api.yaml (put "hello world" in this file, I know it's invalid YAML, but it doesn't matter)
  1. Run npx @redocly/cli lint api/providers/*/api.yaml in the root folder

Expected behavior

I would expect to see the following text with an error on screen:

No configurations were provided -- using built in recommended configuration by default.

validating api/providers/test-provider/api.yaml...
Something went wrong when processing api/providers/test-provider/api.yaml:

  - Document must be JSON object, got string.

Actual behavior

Nothing is displayed. Command exits with exit code 1.

Node.js Version(s)

20

Additional context

I managed to find the cause of this issue. When lint is called we get the following sequence of calls:

handleLint               // redocly-cli/packages/cli/src/commands/lint.ts:      line 40
getgetFallbackApisOrExit // redocly-cli/packages/cli/src/commands/lint.ts:      line 41
expandGlobsInEntrypoints // redocly-cli/packages/cli/src/utils/misceleneous.ts: line 51

And in the expandGlobsInEntrypoints we have this line:

 ? (await glob.__promisify__(aliasOrPath)).map((g: string) => getAliasOrPath(config, g))

You can see the call to __promisify__ function which does not exist on glob. I don't really know the reason why @types/glob added this, but the function does not exist and the correct way to promisify this would be:

// redocly-cli/packages/cli/src/utils/misceleneous.ts
import { promisify } from 'utils';

// expandGlobsInEntrypoints
/* line 109 */ await promisify(glob)(aliasOrPath).map(...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants