dos2unix

A Node.js module to convert text files with DOS line breaks to Unix line breaks, i.e. like using dos2unix.

dos2unix

A Node.js module to convert text files with DOS line breaks to Unix line breaks, i.e. like using dos2unix. The module also supports cross-platform globbing patterns.

Install the module with: npm install dos2unix

var converter = require('dos2unix');
converter.dos2unix('docs/README.txt', function(err) {
  // Callback! 
});
// Reference the module 
var converter = require('dos2unix');
 
// A callback function 
var d2uCallback = function(err) {
  // Callback! 
};
 
// Convert line endings of a single non-binary, non-irregular file from 
// '\r\n' to '\n'. 
converter.dos2unix('docs/README.txt', d2uCallback);
 
// Convert the line endings of multiple non-binary, non-irregular files from 
// '\r\n' to '\n'. 
converter.dos2unix(['docs/README.txt', 'examples/HelloWorld.js'], d2uCallback);
 
// Convert the line endings of all non-binary and non-irregular files in the 
// 'docs' directory (non-recursively) from '\r\n' to '\n'. 
converter.dos2unix('docs/*', d2uCallback);
 
// Convert the line endings of all non-binary and non-irregular files under the 
// 'examples' directory (RECURSIVELY) from '\r\n' to '\n'. 
converter.dos2unix('examples/**/*', d2uCallback);
 
// Convert the line endings of all non-binary and non-irregular files in the 
// 'docs' directory (non-recursively) AND the same type of files under the 
// 'examples' directory (RECURSIVELY) from '\r\n' to '\n'. 
converter.dos2unix(['docs/*', 'examples/**/*'], d2uCallback);

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

  • 0.1.0: Published to NPM on yyyy-mm-dd _(not yet published!)_.
    • Initial release.

Copyright (c) 2013 James M. Greene
Licensed under the MIT license.