A small CLI utility to compare two "build" folders, and copy out the differences between them.
Both of these come standard with macOS and probably most linux/unix flavors.
$ npm install -g @designory/build-diff
# or
$ yarn global add @designory/build-diff
$ build-diff [options] <old-build-directory> <new-build-directory>
-q, --quiet Hides progress as it compares the directories. Defaults to false.
-j, --json Outputs results as JSON. Defaults to false.
-o, --output <name> Name of the output folder and ZIP file. Defaults to "build_for_upload".
Given two folders old/
and new/
, whose contents are shown below:
old/
βββ deleted.txt
βββ unchanged.txt
βββ updated.txt
new/
βββ new.txt
βββ sub/
βΒ Β βββ file.txt
βββ unchanged.txt
βββ updated.txt
Diffing the two folders yields:
$ build-diff old new
Comparing "old" against "new"...
Diffing directories... Done
Parsing diff results... Done
Copying over changed files... Done
Zipping changed files... Done
The following files were deleted:
deleted.txt
The following files were changed:
new.txt
sub
updated.txt
All changed files have been copied to build_for_upload, and zipped in build_for_upload.zip
When using the --quiet
and --json
flag, I can pipe the output to jq and view the results as a formatted JSON string.
$ build-diff --quiet --json old new | jq
{
"filesDeleted": [
"deleted.txt"
],
"filesChanged": [
"new.txt",
"sub",
"updated.txt"
],
"outputDir": "build_for_upload",
"outputZip": "build_for_upload.zip"
}
To specificy a different output directory and zip name, simply set the --output
argument.
$ build-diff --output=my_folder old new
...
All changed files have been copied to my_folder, and zipped in my_folder.zip