Add logic to skip hidden files when including non-FSH IG resources#580
Conversation
This prevents an error when macOS silently adds a `.DS_Store` file
to one of the folders in `ig-data/input/{supported-resource-input-directory}/`.
ngfreiter
left a comment
There was a problem hiding this comment.
Thanks for the PR! There is one small change that would be good before merging, but all looks good besides that.
src/fhirdefs/load.ts
Outdated
| let resourceJSON: any; | ||
| try { | ||
| if (file.endsWith('.json')) { | ||
| if (file.startsWith('.')) { |
There was a problem hiding this comment.
We have come across this situation in a different part of our code, and there we used a package called junk to filter out hidden files like .DS_Store but also certain Windows hidden files like Thumbs.db. I think it would be best to be consistent and use that here as well. To use junk, you'd want to add:
import junk from 'junk';
to the top of load.ts, and then line 197 would be something like:
if (junk.is(file)) {
The junk.is function just tests if the filename is on junks list of system files.
|
@masnick -- we're hoping to do a release of SUSHI today. If you can fix up this PR today, we can get it in the release... |
|
If you can't we'll just hold it for the next release then. |
|
@ngfreiter thanks for the review, I've done as you suggested. @cmoesel assuming the automated checks pass this should be ready to go into the release. I'm stepping away for a few hours now so I won't be able to fix problems immediately, so if this gets bumped to the next release because of that that's ok with me :) |
|
Ok, the checks passed and I tested this locally to ensure it works as intended. I think it's ready to merge in unless you see other issues. Thanks! |
This prevents an error when macOS silently adds a
.DS_Storefile to one of the folders inig-data/input/{supported-resource-input-directory}/.I ran into this when trying to include some
.jsonformat instances in an IG underig-data/input/examples/. When modifying the .json files in theexamples/folder, macOS will sometimes silently add a.DS_Storefile intoexamples/.When this happens, the
sushicommand will fail with a generic "Invalid file detected in directory /path/to/examples/" message. Because the.DS_Storefile is hidden by the OS in Finder, this issue is hard to debug.This change will ignore any files that begin with
.to avoid this problem.