Skip to content

Conversation

haggholm
Copy link
Contributor

@haggholm haggholm commented Sep 27, 2018

Fixes #5122

If no file type can be inferred, this attempts to read the first line of a file and extract a shebang, which can be checked against a known list.

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory) There doesn’t seem to be any documentation on type inference to update.
  • I’ve read the contributing guidelines.

…volves opening and reading (the first line) of the file just to detect the type, (a) do this check last and (b) cache it lazily.
…ily, extract just the interpreter executable name from shebangs, rather than comparing shebangs as a whole.
@alexander-akait
Copy link
Member

Just information: we have same request in plugin-php, maybe it is good to add tests for plugin too

…committed PHP test. Add unknown-shebang test.
@haggholm
Copy link
Contributor Author

haggholm commented Oct 3, 2018

@ikatyang I’m not a very experienced contributor in general, let alone here: I see I have a failing codecov check, but I’m not sure if it’s significant. Should I do anything else to have this merged?

@ikatyang
Copy link
Member

ikatyang commented Oct 3, 2018

You could add some // istanbul ignore next for those untested (and also no need to test) catch branch to make codecov happy, though it's optional.

I generally wait for one day or two after I approved it to see if there's any comment from other maintainers, I'll merge it then if there's no objection.

@ikatyang ikatyang merged commit 1244729 into prettier:master Oct 5, 2018
@ikatyang
Copy link
Member

ikatyang commented Oct 5, 2018

Thanks!

@azz
Copy link
Member

azz commented Oct 7, 2018

Awesome! Will this work with #!node? (I see that kind of shebang every now and again)

@haggholm
Copy link
Contributor Author

haggholm commented Oct 7, 2018

Awesome! Will this work with #!node? (I see that kind of shebang every now and again)

Not the way I wrote it in this PR—I’ve never seen that kind of shebang, so I didn’t know to look for it. But it should be trivial to add that.

@aleclarson
Copy link

Was this ever released?

Both this PR and the issue it fixes were never mentioned in the changelog. ☺️

@haggholm
Copy link
Contributor Author

@aleclarson I’m pleased to say it was merged and released; indeed I can’t see it in the changelog, but it’s mentioned in the blog: https://prettier.io/blog/2018/11/07/1.15.0.html#api-cli

And our build scripts are much Prettier.

@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Mar 22, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 22, 2019
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants