A Node.js module to convert text files with DOS line breaks to Unix line breaks, i.e. like using
The module also supports cross-platform globbing patterns.
Install the module with:
npm install dos2unix
var D2UConverter = dos2unix;var d2u = glob: cwd: __dirname;d2u;
// Reference the modulevar D2UConverter = 'dos2unix'dos2unix;// Setup default optionsvar defaultOptions =glob:cwd: __dirnamemaxConcurrency: 50;// Create a new `dos2unix` instance and add important event listenersvar d2u = defaultOptions;// Convert line endings of a single non-binary, non-irregular file from// '\r\n' to '\n'.d2u;// Convert the line endings of multiple non-binary, non-irregular files from// '\r\n' to '\n'.d2u;// Convert the line endings of all non-binary and non-irregular files in the// 'docs' directory (non-recursively) from '\r\n' to '\n'.d2u;// Convert the line endings of all non-binary and non-irregular files under the// 'examples' directory (RECURSIVELY) from '\r\n' to '\n'.d2u;// 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'.d2u;// Override the globbing options (per the `glob` module's documentation)var globOptions =glob:cwd: 'docs';d2u;
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.
maxConcurrencyconfig default value to
0("unlimited"). Also updated a little code so that a
maxConcurrencyconfig value of
0or less will result in "unlimited", i.e. process the whole array of globbed files at once.
maxConcurrencyconfig options to throttle how many files can be processed simultaneously. This helps avoid issues across the board as most systems have an implicit number of file handles that can be opened as once. It also provides those running on hardware with limited resources to maintain better control of consumption.
asyncmodule to replace
q, particularly for its
console.errorcall to an event emission as intended.
globcommand was executed relative to a different directory.
Copyright (c) 2013 James M. Greene
Licensed under the MIT license.