clausreinke / typescript-tools

(repo no longer active) Tools related to the TypeScript language
Apache License 2.0
266 stars 29 forks source link

Use Unix encoding for newlines in bin/tss #32

Closed gracjan closed 10 years ago

gracjan commented 10 years ago

TSS as distriubuted via melpa has DOS end-of-line encodings for bin/tss. This makes unix shell look for "node\r" instead of "node".

This seems to be a git feature that it checks out bin/tss in text mode with CRLF on Windows and LF on Unix so that if you create melpa package on Windows you get CRLF in text files. Usually it does not matter but causes bash to stumble. Exact message:

~/node_modules/typescript-tools/bin:$ ./tss
env: node\r: No such file or directory

Please make sure that LF is used for unix scripts always.

clausreinke commented 10 years ago

Thanks for the report. I have no experience with melpa, but your prompt suggests that it uses npm to install typescript-tools. And indeed, when I git clone the repo on ubuntu, with default settings, the EOLs seem to cause no trouble, while an npm install has the CRLFs and can't run bin/tss.

Will fix for next npm package update.

Bartvds commented 10 years ago
env: node\r: No such file or directory

This is definitely a real problem: I publish my own projects from a Windows machine and my Linux users reported it too.

A extra problem was that Git likes to mess with auto newline conversions so the problem came back after checkouts.

It is easy to solve with a simple string replace in the npm pre-publish script.

gracjan commented 10 years ago

Git manual suggests that putting a line bin/tss eol=lf in .gitattributes would tell git to always use unix eol for this specific file independent of current system. I did not test as I do not have Windows machine handy.

Bartvds commented 10 years ago

That certainly works for checkouts, but it still breaks when your IDE or some other tool interferes and add CRLF's again (learned this the hard way).

So if you want to be 100% sure it is safest to do a replace in the npm prepublish.

clausreinke commented 10 years ago

should be fixed in npm package version 0.3.1