-
Notifications
You must be signed in to change notification settings - Fork 150
Repaired require for default .gemini.js
and .gemini.json
#418
Repaired require for default .gemini.js
and .gemini.json
#418
Conversation
Gah, I forgot to point to |
Oh, never mind. There's a https://github.com/gemini-testing/gemini/blob/v3.0.2/CONTRIBUTING.md |
@@ -76,6 +76,11 @@ function getDefaultConfig() { | |||
throw new GeminiError('No config found'); | |||
} | |||
|
|||
if (!/\.yml$/.test(configFile)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can do it for yml
file too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing. I initially left yml
out to prevent long paths in case there was an error later and it popped up in the stack trace.
6a34899
to
8d9e3c9
Compare
Alright, I have addressed the comments and updated the PR:
|
@twolfson Thanks, but I was thinking about some unit-tests may be. And thats not a good idea to make |
Ah, alright. I think using unit tests will be too overwhelming for me. With respect to the current status, it's possible to have the same result in
However, I will leave the PR as is until your exploration with unit tests. |
…ectory For example working directory is `/home/foo/project_with_gemini/gemini/`. We use js or json default path configuration or use `-c` option. Run `./gemini` or `./gemini -c .very_special_configuration.json`. And we get configuration relative to current working directory: /home/foo/project_with_gemini/gemini/.gemini.conf.json /home/foo/project_with_gemini/gemini/.gemini.conf.js /home/foo/project_with_gemini/gemini/.very_special_configuration.json not in directory anywhere in the node_modules. Fixed gemini-testing#418.
…ectory For example working directory is `/home/foo/project_with_gemini/gemini/`. We use js or json default path configuration or use `-c` option. Run `./gemini` or `./gemini -c .very_special_configuration.json`. And we get configuration relative to current working directory: /home/foo/project_with_gemini/gemini/.gemini.conf.json /home/foo/project_with_gemini/gemini/.gemini.conf.js /home/foo/project_with_gemini/gemini/.very_special_configuration.json not in directory anywhere in the node_modules. Fixed gemini-testing#418.
…ectory For example working directory is `/home/foo/project_with_gemini/gemini/`. We use js or json default path configuration or use `-c` option. Run `./gemini` or `./gemini -c .very_special_configuration.json`. And we get configuration relative to current working directory: /home/foo/project_with_gemini/gemini/.gemini.conf.json /home/foo/project_with_gemini/gemini/.gemini.conf.js /home/foo/project_with_gemini/gemini/.very_special_configuration.json not in directory anywhere in the node_modules. Fixed gemini-testing#418.
Glad to hear it's been patched. Fwiw, #442 doesn't seem to have any tests to prevent this regression from recurring (i.e. nothing verifying default path is absolute) =/ |
https://github.com/gemini-testing/gemini/pull/442/files#diff-7cd03a08e3e1393e232f4490c33a335aR22 |
That line is a mock setup in the test, it doesn't verify that the actual https://github.com/gemini-testing/gemini/pull/442/files#diff-435eaee6ef8a8a771ac5e6ca51dac9d6R26 |
Those tests will fail without that line. Take a look at this commit: 88de4a9 |
After playing around with it myself, I realized what is going on:
As a heads up, while this works for now it will cause a maintenance tax any time the implementation is changed (e.g. moving to I should also note that that PR doesn't test |
And there's also no test for what happens when no config is found =/ |
Yep, we doesn't have 100% coverage. And we write tests when we see bug or on some code modification. |
I'm experimenting with a script that requires a dynamically computed
.gemini.js
(depends on node module for path to executable). However, when I ran Gemini I saw that it was getting aMODULE_NOT_FOUND
error for.gemini.js
despite it working earlier for.gemini.yml
.After some digging, I found that we were essentially running
require('.gemini.js')
which tells Node.js to look for a package named.gemini.js
instead of the local file (i.e../.gemini.js
). I have resolved that in this PR by moving to an absolute path for.gemini.js
/.gemini.json
.In this PR:
getDefaultConfig
to return absolute path for non-YAML filesNotes:
We could use
fs.readFile
andJSON.parse
/vm.runInContext
(sincefs.readFile
resolves fromprocess.cwd()
but this is much simpler.