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

Prettier 1.4 deletes shebang #1890

Closed
anmonteiro opened this issue Jun 2, 2017 · 5 comments · Fixed by #1899 or renovatebot/renovate#233
Closed

Prettier 1.4 deletes shebang #1890

anmonteiro opened this issue Jun 2, 2017 · 5 comments · Fixed by #1899 or renovatebot/renovate#233
Assignees
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program

Comments

@anmonteiro
Copy link
Contributor

I have a file in which Prettier deleted the #!/usr/bin/env node shebang line.

I'm not sure what more info you need to diagnose this, please let me know what else I can provide!

@vjeux
Copy link
Contributor

vjeux commented Jun 2, 2017

@josephfrazier, looks like your shebang fixed broke it :(

@anmonteiro
Copy link
Contributor Author

anmonteiro commented Jun 2, 2017

Minimal repro:

$ cat x.js
#!/usr/bin/env node
'use strict';

var x = 42;
$ ./node_modules/.bin/prettier x.js
"use strict";

var x = 42;

@vjeux vjeux added the type:bug Issues identifying ugly output, or a defect in the program label Jun 2, 2017
@josephfrazier
Copy link
Collaborator

josephfrazier commented Jun 2, 2017

:( Oops, I'll take a look

EDIT: the fix @vjeux mentioned: #1718

@josephfrazier josephfrazier self-assigned this Jun 2, 2017
@josephfrazier
Copy link
Collaborator

josephfrazier commented Jun 2, 2017

Hmm, looks like this has something to do with the CLI, as the API appears to be working correctly: https://runkit.com/josephfrazier/runkit-npm-prettier-issue1890 See EDIT below

var prettier = require("prettier")

prettier.format(`#!/usr/bin/env node
'use strict';

var x = 42;`)
#!/usr/bin/env node
"use strict";

var x = 42;

EDIT: Aha, it's formatWithCursor that's broken:

var prettier = require("prettier")

prettier.formatWithCursor(`#!/usr/bin/env node
'use strict';

var x = 42;`).formatted
"use strict";

var x = 42;

josephfrazier added a commit to josephfrazier/prettier that referenced this issue Jun 2, 2017
This fixes prettier#1890, albeit in a
quick-and-dirty way. Note also that the cursor offset may be incorrect
when there is a shebang, but that's a separate issue.
vjeux pushed a commit that referenced this issue Jun 2, 2017
This fixes #1890, albeit in a
quick-and-dirty way. Note also that the cursor offset may be incorrect
when there is a shebang, but that's a separate issue.
@vjeux
Copy link
Contributor

vjeux commented Jun 2, 2017

I just published 1.4.1 which fixes it!

@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jul 7, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
3 participants