I'm no longer developing npm-text-auto. I have decided it's better to disable autocrlf and stick to LF line endings on all platforms. I highly recommend you do that same.
This module has not been completely tested and should be considered a beta. It's intended to modify your source files, so use with caution. Bug reports and pull request are welcome.
Before publishing, npm-text-auto
converts text files to Unix style line endings (\n). After publishing, it converts them back to the default line ending for your OS (ie. \r\n for Windows).
This acts like having * text=auto
in your .gitattributes file, only for npm publish.
npm-text-auto
can be used as a local module or run from the command line.
-
Install as a development dependency
npm install npm-text-auto --save-dev
-
Add hook scripts to
package.json
"scripts": { "prepublish": "npm-text-auto", "postpublish": "npm-text-auto" }
-
Publish
-
Install as a global module
npm install npm-text-auto -g
-
Run the hook manually:
npm-text-auto prepublish npm-text-auto postpublish
- On systems where the default EOL is \n,
npm-text-auto
does not modify any files. - The binary file detection method as the same as GIT. It checks the first 8000 bytes for the presence of a null byte.
- File modified timestamp is preserved.
- Files with mixed EOL styles are convert to the correct EOL.
- The
.npmignore
(or.gitignore
) file are processed using the same module as npm. Excluded files will not have their EOL modified. package.json
, files innode_modules
, and files in version control directories files (.git
.hg
.svn
CVS
) are never modified..gitattributes
is not supported. If enough people need this, I may add it.