Skip to content

romellem/build-diff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Build Diff

npm version

A small CLI utility to compare two "build" folders, and copy out the differences between them.

Requirements

Both of these come standard with macOS and probably most linux/unix flavors.

Install

$ npm install -g @designory/build-diff
# or
$ yarn global add @designory/build-diff

Usage

$ build-diff [options] <old-build-directory> <new-build-directory>

Options

  -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".

Examples

Standard Example

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

--quiet and --json Flags

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"
}

--output Flag

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

License

MIT