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

Support registering custom file extensions #231

Merged
merged 1 commit into from
Jan 27, 2022

Conversation

dukeofsussex
Copy link
Contributor

When this library still used require-all, it was possible to load TS files during dev with

.registerCommandsIn({
  filter: /^([^.].*)\.(?:js|ts)$/,
  dirname: join(__dirname, 'commands'),
})

This is no longer possible since 5.x, so this PR aims at supporting it out-of-the-box.

@dukeofsussex dukeofsussex requested a review from Snazzah as a code owner January 26, 2022 16:51
@Snazzah
Copy link
Owner

Snazzah commented Jan 27, 2022

I'm pretty sure just enabling this outright may create a bunch of errors, could this be an argument to enable instead?

@Snazzah Snazzah added semver: patch PRs that contain bugfixes and will be on the next patch release type: enhancement New feature or request labels Jan 27, 2022
@dukeofsussex
Copy link
Contributor Author

I'm interested as to why or how it would cause issues, but I can gladly change it to something like

  registerCommandsIn(commandPath: string, endings: string[] = ['.js', '.cjs'])

@fangmarks
Copy link

I'm interested as to why or how it would cause issues, but I can gladly change it to something like

I'm pretty sure Typescript generates .d.ts files when you set "declaration": true in your tsconfig.json, which would then cause slash-create to load those files and cause various issues.

Personally I like the option you posted, though I'd make passing endings optional xP

@dukeofsussex
Copy link
Contributor Author

I'm pretty sure Typescript generates .d.ts files when you set "declaration": true in your tsconfig.json, which would then cause slash-create to load those files and cause various issues.

Good point, hadn't thought of the declaration files. Also the proposed solution already makes passing endings optional, but maybe it should be changed to an optional additionalEndings instead.

@Snazzah
Copy link
Owner

Snazzah commented Jan 27, 2022

Good point, hadn't thought of the declaration files. Also the proposed solution already makes passing endings optional, but maybe it should be changed to an optional additionalEndings instead.

Yeah, this is alright.

@Snazzah Snazzah changed the title Support .ts file extensions Support registering custom file extensions Jan 27, 2022
@Snazzah Snazzah added semver: minor PRs that contain new features and will be on the next minor release and removed semver: patch PRs that contain bugfixes and will be on the next patch release labels Jan 27, 2022
@Snazzah Snazzah merged commit 9b399ba into Snazzah:master Jan 27, 2022
@dukeofsussex dukeofsussex deleted the register-ts branch February 2, 2022 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: minor PRs that contain new features and will be on the next minor release type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants