Skip to content
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

fix(inject): Improve fixup_js_file #1533

Merged
merged 5 commits into from
Mar 24, 2023
Merged

fix(inject): Improve fixup_js_file #1533

merged 5 commits into from
Mar 24, 2023

Conversation

loewenheim
Copy link
Contributor

@loewenheim loewenheim commented Mar 17, 2023

  • Removes an unnecessary newline before the injected content
  • In the event that the source file contains multiple //# sourceMappingURL comments (as is the case for one of our tests), the last one will be moved to the end of the file (after the injected content) and the others will be left alone. Previously, the others were deleted.
  • Always writes a newline at the end of the file

writeln!(js_contents, "{to_inject}")?;
writeln!(js_contents, "{DEBUGID_COMMENT_PREFIX}={debug_id}")?;

if let Some(sourcemap_comment) = sourcemap_comment {
write!(js_contents, "{sourcemap_comment}")?;
writeln!(js_contents, "{sourcemap_comment}")?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for context…
it might be the case that users are still post-processing stuff after a sentry-cli run, like blindly concatenating two files, in which case we would break as the first line of the concatenated file would be commented out, and the 2nd line would have a syntax error

@loewenheim
Copy link
Contributor Author

I added a test that contains empty lines (to make sure that we're not semi-overwriting the previous contents due to skipping those) and makes a filesystem roundtrip.

@loewenheim loewenheim enabled auto-merge (squash) March 24, 2023 16:06
@loewenheim loewenheim merged commit d325a3f into master Mar 24, 2023
@loewenheim loewenheim deleted the fix/inject-fixup-js branch March 24, 2023 16:16
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.

None yet

2 participants