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 ts-node by checking .ts source files #47

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

marshall007
Copy link

Should fix #41, but I haven't been able to test yet.

I still have a few more cases to update like in help.ts#L108-L117, but I wanted to run this PR by you before continuing (mostly because I'm unsure how we should go about adding tests for this).

For what it's worth, I also don't think this is a good long-term solution. I would really like to see #43 implemented, but this seemed like the easier path forward for now to get my feet wet.

@marshall007
Copy link
Author

Note the build failures already existed on master and are not a result of this change.

@vilicvane
Copy link
Owner

vilicvane commented May 1, 2018

Hi @marshall007 , thanks for this PR. Yes the CI failure was caused by an accidentally committed file by me.

Along with other feature requests, I think there would be a major refactoring for clime in the near future.

And this is PR is has some intersections with #42 , which addresses this issue in a configurable approach. I am actually okay with both, so it would be nice if you may update the correspondent part of help.ts.

As for tests, you can check out https://github.com/vilic/clime/blob/master/src/test/baseman/cli-test.ts#L45

I think maybe we can simply duplicate all .js tests for .ts by generating both of them.

@marshall007
Copy link
Author

@vilic I just pushed up another commit addressing the remaining cases in help.ts. Could still use some direction on testing. I can't really tell how the generator works. Perhaps it would be easier to just run baseman with ts-node prior to compiling the TS test source files?

@vilicvane
Copy link
Owner

@marshall007 You might be right. We need some efforts on baseman implementation though. I will make necessary changes to baseman and test case generating here, and once done will merge your PR (if it passes). Thanks!

@marshall007
Copy link
Author

@vilic no problem, just let me know if you need anything else! Cheers!

@@ -11,6 +12,28 @@ export async function existsFile(path: string): Promise<boolean> {
return !!stats && stats.isFile();
}

export async function existsSourceFile(path: string, filename: string = 'default'): Promise<string | undefined> {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not simply use require.resolve to resolve a module with any supported file extension?

@marshall007
Copy link
Author

@ajafff good call on using require.resolve, just updated this PR to do so. Note I rebased on top of 0e075f1 to get rid of those test failures. The existing (JS-based) tests still passed on my local using the new require.resolve logic.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.007%) to 97.578% when pulling 4ef9e9a on marshall007:marshall_41 into 0e075f1 on vilic:master.

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

Successfully merging this pull request may close these issues.

sample code doesn't work (with ts-node)
4 participants