This repository has been archived by the owner on Mar 10, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for alternative config files with cosmiconfig (#178)
Fixes #118 Introduces `cosmiconfig` as requested in #118 in order to support loading the config from alternative file formats like: ``` .unimportedrc.js .unimportedrc.yml package.json > "unimported" key ``` I'm using `cosmiconfigSync` utilities instead of the async version, despite them being available since the `getConfig` is an async method. When we use the async equivalent, we hit a segfault in Node as a result of `cosmiconfig` trying to call a dynamic import on the file within a Jest context that doesn't allow it to. Patched in a recent version of Node, and once the test infra can require the latest version it should be fine to switch to the async version. See nodejs/node#35889 and jestjs/jest#11438 I haven't made any efforts to change the `update` function to write updates to the loaded files, as this would be difficult/impossible to update something like a .js or .yml (if using features like anchors) in a meaningful way. A few notes on the other changes included: 1. `cosmiconfig` pulls in a newer version of TypeScript which was incompatible with the version of `@types/node` we used, updated it 2. One of the tests produced invalid JSON to a config file, which failed silently before and passed the test, but now fails loudly when `cosmiconfig` tries to read and parse the JSON. Updated it to be valid to fulfill the spirit of the test. --------- Co-authored-by: Stephan Meijer <stephan.meijer@gmail.com>
- Loading branch information
1 parent
7af1e39
commit 70ef403
Showing
4 changed files
with
147 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters