Skip to content

fix(scripts): Strip trailing line comments before @import parsing#2242

Draft
elnelson575 wants to merge 1 commit into
mainfrom
fix/upgrade-deps-import-comment-parsing
Draft

fix(scripts): Strip trailing line comments before @import parsing#2242
elnelson575 wants to merge 1 commit into
mainfrom
fix/upgrade-deps-import-comment-parsing

Conversation

@elnelson575
Copy link
Copy Markdown
Contributor

Summary

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, the regex matches only the prefix and gsub leaves the trailing comment glued to the filename, producing a bogus path and aborting make upgrade-html-deps with Could not find file: ....

This currently triggers on upstream bslib's inst/lib/bs5/scss/_variables.scss, which contains:

@import "variables-dark"; // TODO: can be removed safely in v6, only here to avoid breaking changes in v5.3

theme_files_used() then tries to resolve a file literally named variables-dark // TODO: can be removed safely in v6, … and aborts.

Fix

Strip \s*//.*$ from each candidate import line before the path-extraction gsubs, so trailing line comments no longer leak into the matched filename. One-line change.

Test plan

  • Verify make upgrade-html-deps completes successfully on current rstudio/bslib@main
  • Verify the generated shiny/www/shared/sass/ tree looks unchanged vs. the previous successful run (no missing/extra imports)

`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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant