@x1289/format-files

1.0.1 • Public • Published

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';
});

/@x1289/format-files/

    Package Sidebar

    Install

    npm i @x1289/format-files

    Weekly Downloads

    0

    Version

    1.0.1

    License

    ISC

    Unpacked Size

    2.82 kB

    Total Files

    4

    Last publish

    Collaborators

    • x1289user