1.0.1 • Published 3 years ago

@x1289/format-files v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

format-files

Small script to format all files in a directory

npm i @x1289/format-files

API:

handleAllFiles(dirPath, formatFunc)

dirPath: Path to directory to format.
formatFunc: Function to apply to every line of every file in the directory.

formatFile(filePath, formatFunc)

filePath: File to format.
formatFunc: Function to apply to every line of every file in the directory.

Example

To remove all trailing whitespaces and add uniform EOL character

const { handleAllFiles } = require('format-files')

await handleAllFiles('./testing/', (str) => {
return str.trimRight() + '\n';
});

To make every line uppercase

const { handleAllFiles } = require('format-files')

await handleAllFiles('./testing/', (str) => {
return str.toUpperCase() + '\n';
});