Repaired require for default .gemini.js and .gemini.json#418
Repaired require for default .gemini.js and .gemini.json#418twolfson wants to merge 1 commit intogemini-testing:masterfrom
.gemini.js and .gemini.json#418Conversation
|
Gah, I forgot to point to |
|
Oh, never mind. There's a https://github.com/gemini-testing/gemini/blob/v3.0.2/CONTRIBUTING.md |
lib/config/index.js
Outdated
| throw new GeminiError('No config found'); | ||
| } | ||
|
|
||
| if (!/\.yml$/.test(configFile)) { |
There was a problem hiding this comment.
I think we can do it for yml file too
There was a problem hiding this comment.
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_FOUNDerror for.gemini.jsdespite 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.jsinstead 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:
getDefaultConfigto return absolute path for non-YAML filesNotes:
We could use
fs.readFileandJSON.parse/vm.runInContext(sincefs.readFileresolves fromprocess.cwd()but this is much simpler.