fix(scripts): Strip trailing line comments before @import parsing#2242
Draft
elnelson575 wants to merge 1 commit into
Draft
fix(scripts): Strip trailing line comments before @import parsing#2242elnelson575 wants to merge 1 commit into
@import parsing#2242elnelson575 wants to merge 1 commit into
Conversation
`theme_files_used()` in `scripts/_functions_sass.R` extracts imported file paths from SCSS `@import` lines using a regex that requires the line to end with `";`. When an `@import` has a trailing line comment (e.g. `@import "variables-dark"; // TODO: ...`), the regex matches only the prefix and `gsub` leaves the trailing comment glued to the filename, producing a bogus path like `variables-dark // TODO: can be removed safely in v6, ...` and aborting `make upgrade-html-deps` with "Could not find file". This currently triggers on upstream bslib's `inst/lib/bs5/scss/_variables.scss` line `@import "variables-dark"; // TODO: can be removed safely in v6, only here to avoid breaking changes in v5.3`. Strip `\\s*//.*$` from each candidate import line before the path-extraction gsubs so trailing comments no longer leak into the matched filename.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
theme_files_used()inscripts/_functions_sass.Rextracts imported file paths from SCSS@importlines using a regex that requires the line to end with";. When an@importhas a trailing line comment, the regex matches only the prefix andgsubleaves the trailing comment glued to the filename, producing a bogus path and abortingmake upgrade-html-depswithCould not find file: ....This currently triggers on upstream bslib's
inst/lib/bs5/scss/_variables.scss, which contains:theme_files_used()then tries to resolve a file literally namedvariables-dark // TODO: can be removed safely in v6, …and aborts.Fix
Strip
\s*//.*$from each candidate import line before the path-extractiongsubs, so trailing line comments no longer leak into the matched filename. One-line change.Test plan
make upgrade-html-depscompletes successfully on currentrstudio/bslib@mainshiny/www/shared/sass/tree looks unchanged vs. the previous successful run (no missing/extra imports)