facebook / jscodeshift

A JavaScript codemod toolkit.
https://jscodeshift.com
MIT License
9.11k stars 468 forks source link

Easiest way to insert a comment at the beginning of a file? #569

Closed brexmatt closed 9 months ago

ayushsgithub commented 10 months ago

Screenshot 2023-09-22 122151

The first comment is in Python. The second comment is in HTML. The third comment is in CSS. The fourth comment is in Bash. The fifth comment is another HTML comment. The last comment is in Markdown (using an HTML-style comment).

ElonVolo commented 9 months ago

Putting a comment line at the beginning of the file is probably one of the few cases where I'd just do straight-up concatenation over generating code.

Just open file, read contents into string, and prepend the line to the file's string contents.

I also tried ChatGPT and it generated something convincing.

brexmatt commented 9 months ago

Putting a comment line at the beginning of the file is probably one of the few cases where I'd just do straight-up concatenation over generating code.

Just open file, read contents into string, and prepend the line to the file's string contents.

I also tried ChatGPT and it generated something convincing.

thanks