file-flattener
v1.0.3
Published
File flattener
Downloads
1
Readme
File Flattener
A Node.js tool to consolidate and organize text files by extension into a single output file, with customizable inclusion and exclusion rules.
Installation
Install the package using npm:
npm install -g file-flattener
Usage
After installation, the tool can be used from the command line as follows:
flatten --extensions <file-extensions> --blacklist <blacklisted-directories>
--extensions, -e
: A comma-separated list of file extensions to include (e.g.,.js,.txt
).--blacklist, -b
: A comma-separated list of directories to exclude (e.g.,node_modules,dist
). --negExtensions, -n
: A comma-separated list of file extensions to exclude (e.g., .log,.bak
).
The script will output the contents of the included files to the console, each prepended with its relative file path.
Example
flatten -e ".js,.html" -b "node_modules,dist" -i ".log,.bak"
This will output to the console the contents of all .js
and .html
files, excluding any within node_modules
or dist
directories and any files with .log
or .bak
extensions.
Advanced Features
- The tool performs a simple binary check to determine if a file is a text file and should be included.
- The output includes the relative path of each file for better organization.