-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: exclusion file and tests #5061
Conversation
Hi @rudouglas 👋 Gatsby Cloud will automatically generate a preview of your request, and will comment with a link when the preview is ready (usually 20 to 30 minutes). |
const getExclusions = () => { | ||
return yaml.load(fs.readFileSync(path.join(process.cwd(), EXCLUSIONS_FILE))); | ||
}; |
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 this can just be moved into excludeFiles, or still be kept as a separate method but called directly from excludeFiles.
additionally, i think its cleaner & would allow for us to simplify the signature of excludeFiles, since we wouldn't need to pass exclusions
parameter anymore.
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.
The only trade-off with that is we would be running yaml.load
and fs.readFileSync
for every file, would it not make more sense to only perform that action once?
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.
if you run it like this, would it run more than once? i might've missed a loop somewhere, is this what you meant @nr-kkenney? :
const excludeFiles = (fileData) => {
const exclusions = getExclusions();
return fileData.filter(({ filename, locale, contentType }) => {
const localeKey = Object.keys(LOCALE_IDS).find(
(localeKey) => LOCALE_IDS[localeKey] === locale
);
return (
!exclusions.excludePath[localeKey]?.some((path) =>
filename.startsWith(path)
) && !exclusions.excludeType[localeKey]?.some((type) => contentType === type)
);
});
};
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.
ahhh i misunderstood what you meant Kris, that does make complete and utter total sense
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.
Looks great overall! I just think I found one small bug!
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.
Overall looks great! Just noticed one thing in the exclusions file
This adds the ability to exclude files under specific paths, and of specific types which are configured using a YAML file.
This also adds tests to the add-files-to-translation-queue workflow as there weren't any before, and adds tests for excluding files/types