Directory Compare CLI

1.0.1 · maintenance · verified Wed Apr 22

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.

Common errors

Warnings

Install

Quickstart

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.

# Install globally to make the 'dircompare' command available
npm install -g dir-compare-cli

# Create some dummy directories and files for demonstration
mkdir -p dir1/subdir
echo "Hello from file1" > dir1/file1.txt
echo "Hello from file2" > dir1/subdir/file2.js

mkdir -p dir2/subdir
echo "Hello from file1" > dir2/file1.txt
echo "Modified content" > dir2/subdir/file2.js
echo "New file" > dir2/new_file.txt

# Compare dir1 and dir2 by content, showing only distinct entries
# and include the reason for distinction.
# Exit code 1 indicates differences were found.
dircompare -c -d --reason dir1 dir2

# Clean up dummy directories
rm -rf dir1 dir2

view raw JSON →