Skip to content

[rush-lib] Normalize plugin autoinstaller file line endings#5678

Open
kevin-y-ang wants to merge 1 commit intomicrosoft:mainfrom
kevin-y-ang:fix/rush-lib-autoinstaller-loader
Open

[rush-lib] Normalize plugin autoinstaller file line endings#5678
kevin-y-ang wants to merge 1 commit intomicrosoft:mainfrom
kevin-y-ang:fix/rush-lib-autoinstaller-loader

Conversation

@kevin-y-ang
Copy link
Contributor

@kevin-y-ang kevin-y-ang commented Mar 2, 2026

Summary

  • Update AutoinstallerPluginLoader.ts to read source JSON files and write them with convertLineEndings: NewlineKind.Lf.
  • Apply this behavior to both the plugin manifest and optional command-line JSON file.

Details

  • At TikTok we develop on Mac. When running rush update, AutoinstallerPluginLoader.ts will the line endings of rush-plugin-manifest.json and command-line.json. This creates unstaged changes that causes confusion and inconvenience for developers.
  • This behavior eists because FileSystem.copyFile() does not support the option convertLineEndings: NewlineKind.Lf. This problem can be resolved by reading the file into memory with FileSystem.readFile() and writing it with FileSystem.writeFile() with the convertLineEndings: NewlineKind.Lf option.

How it was tested

  • Testing it on TikTok repos, this removes the issue of Rush changing the line endings of rush-plugin-manifest.json and command-line.json when running rush update.
image

// Use read+write instead of copy to ensure line endings are normalized
const manifestContent: string = FileSystem.readFile(manifestPath);
FileSystem.writeFile(destinationManifestPath, manifestContent, {
convertLineEndings: NewlineKind.Lf
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will this create the opposite problem on Windows?

I wonder if NewlineKind.OsDefault: is better or worse than NewlineKind.Lf. 🤔

@dmichon-msft @iclanton

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image It seems like NewlineKind.Lf is the default option across the codebase, appearing 11 times. image On the other hand, NewlineKind.OsDefault appears 2 times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

2 participants