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

Command discovery does not working in directories that contain files other than javascript #197

Open
thesayyn opened this issue Sep 14, 2020 · 3 comments
Assignees

Comments

@thesayyn
Copy link

Describe the bug
program.discover does not work with typescript compilation outputs.

To Reproduce
Steps to reproduce the behavior:
1- Create a typescript project
2- Create a program
3- Create a directory called commands
4- Put a command into the commands directory
5- Enable command discovery via the discover option.
6- Compile the project

// Javascript or Typescript code to reproduce bug
import {Program} from "@caporal/core";
import * as path from "path";

new Program()
  .discover(path.join(__dirname, "commands"))
  .run();

Expected behavior
Command discovery should not try to require non-javascript files such as typescript declaration files.

Actual behavior
Command discovery is trying to require types such as typescript declarations.

Environment informations (please complete the following information):

  • OS: Mac
  • OS version: Catalina
  • Shell: zsh
  • Caporal version: 2.0.2

Additional context
Add any other context about the problem here.

@thesayyn
Copy link
Author

@mattallty 👋, Any thoughts on this?

@electrotype
Copy link

Related issue here. I have a Typescript project where the .js files are generated beside their associated .ts files.

The commands work, but the global help show each command two times instead of one.

@gregorskii
Copy link

gregorskii commented Oct 11, 2021

New to this lib, but looking at the source in scan I think I see the issue:

https://github.com/mattallty/Caporal.js/blob/master/src/command/scan.ts#L19

This needs to be scoped to include only files that contain commands, thinking more on this it can't just be JS, is there some convention that could be used? {name}.command.js?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants