dir-compare-cli is a command-line interface (CLI) utility built for Node.js that enables users to compare the contents of two directories. It functions as a wrapper around the `dir-compare` library, providing a convenient console interface for directory comparison tasks. Currently stable at version 1.0.1, its release cadence is generally tied to updates and maintenance of its underlying library or when specific CLI-focused enhancements are required. Key differentiators include its robust set of comparison options, allowing comparisons by file size (default), content, modification date, and symlink targets. It also supports powerful file and directory filtering using Minimatch glob patterns, and offers detailed reporting capabilities including CSV output and distinct exit codes for scripting automation.
npm install dir-compare-cliNo compatibility data collected yet for this library.
This example demonstrates how to install the CLI globally and then use it to compare two directories by content, explicitly showing only distinct files and the reason for their differences.
Always add `-c` or `--compare-content` to your command for content-based comparisons: `dircompare -c dir1 dir2`.
In shell scripts, check the `$?` variable (or equivalent) after execution: `dircompare dir1 dir2; if [ $? -eq 1 ]; then echo 'Directories are different.'; fi`.
For stricter date comparison, set `--date-tolerance` to `0` or a very small value: `dircompare -D --date-tolerance 0 dir1 dir2`.
Consult the Minimatch documentation for correct glob pattern syntax. Use relative paths for filters, e.g., `dircompare -x "**/node_modules" dir1 dir2`.
Install the package globally using `npm install -g dir-compare-cli` to make the `dircompare` command available in your system's PATH.
Verify that both directory paths provided to `dircompare` are correct and exist on your filesystem. Use absolute paths or ensure you are running the command from the correct working directory.
Review the command options. Add `-a` or `--show-all` to see a detailed report of all entries and their differences. Explicitly use `-c` for content comparison, `-D` for date, or check for filters that might be excluding relevant files.