{"name":"dir-compare","version":"2.2.0","description":"Node JS directory compare","main":"src/index.js","types":"src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/gliviu/dir-compare.git"},"keywords":["compare","directory","folder"],"dependencies":{"buffer-equal":"1.0.0","colors":"1.0.3","commander":"2.9.0","minimatch":"3.0.2"},"devDependencies":{"@types/node":"^12.11.7","copyfiles":"^1.2.0","memory-streams":"0.1.0","semver":"5.6.0","shelljs":"0.3.0","tar-fs":"1.16.2","temp":"0.9.0","ts-node":"^8.5.4","tslint":"^5.20.0","tslint-config-prettier":"^1.13.0","typescript":"^3.7.4"},"bin":{"dircompare":"src/cli/dircompare.js"},"scripts":{"clean":"rm -rf build && rm -rf .nyc_output && rm -rf coverage","copydeps":"copyfiles \"test/expected/**\" test/testdir.tar package.json build","build":"tsc && npm run copydeps","lint":"tslint -p tsconfig.json","pretest":"npm install && npm run build","test":"node build/test/runTests.js","extest":"npm run pretest && ./test/extended/init.sh && test/extended/runall.sh","coverage":"npx nyc --exclude \"build/test/**\" --reporter=lcov npm test && npx nyc report","toc":"npx markdown-toc README.md; echo \n","docs":"npx typedoc --includeVersion --includeDeclarations --excludeExternals --theme minimal --mode file --readme none --gitRevision master --toc compare,compareSync,fileCompareHandlers,Options,Result --out docs ./src/index.d.ts"},"author":{"name":"Liviu Grigorescu"},"license":"MIT","bugs":{"url":"https://github.com/gliviu/dir-compare/issues"},"gitHead":"5e3b082d2d5b4b762b8fc6fb186a77a582c124df","homepage":"https://github.com/gliviu/dir-compare#readme","_id":"dir-compare@2.2.0","_nodeVersion":"12.13.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-cmOgS23lSolrsdrDSwWdu/USalfXEwQ/4r3MyIur2U/td2pIp8TnO71ME4M8siaE49xg43tIVX3XzriDOgfdow==","shasum":"945ae53b685cba8de7172442c657d5bcbef680b9","tarball":"http://registry-npm.ywwl.com/dir-compare/download/dir-compare-2.2.0.tgz","fileCount":24,"unpackedSize":91404,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeNiAhCRA9TVsSAnZWagAAiucP/RtJ72v+Ckfj9NYpFYaL\n1DCNRRXsMRNcIYMH7QXDUUqtcaIULG7nrXmOwzNOXguZBgtKVz+iiLLESvZw\njTp9Q+C9L5gxCaz6voG/7XtpiF5ruMuQEAEG8yvesH++JfK5xRO7/oTKqVqZ\n3Kzp5Xi7UT+4b/VvK3V2e6GhZMvcH560/+otipD/U4iXe//UwNI71cnaSHoT\n9/nN5sNcgKBMJTsFycLp0clzhgC7qZuJpjkxstBprK0KJBiskoBK2yrdoNgv\nfR9x/NRukOGrHz8kD65yllLTBTvTwojky2b/e2qAFZeaIVjto/bWMISmAWUW\nbxvUy4c7dK499CjsvjM14hzm5ioi8qdZFLs2wS4Q3CqmFD1xSiDSTlJOC8s2\nvZfLLIeAWMhSDGSkFTsFQNrIcHPbD6nAhFMqsJJqBU+ihYnmCOOVT9nqbEe4\nxw+Z1MaGxo01k75rhWw/+vDPqgWZlvbD069/ZYFWKz3ve/uhVnOK+kV2t502\nQ5TRPxYrU7XvlJ9s73+JCikWOtmIGa7jddYjmNkmee/1cy/4ecPuh60LxdaV\nBiIb7TqZU6pMAzFZonmIIHOi1ZeQmIgI5Uc2ZOEQ6AbzNFWifJGBmRpJb9vW\n0+FrFBYTehWvO2oItIS96Cit5sZ8j4le8esThOxA51eYa4cN/3BF2VTt8EpD\ntAPe\r\n=tKWv\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCB/0gWt3xBPeDgplsuwSWbCzduJWYQJ3myR+rq2rra4wIhAI5pNCBuT6cWQWZv0ltWmrP5LfKyLPFjpEMTMFzvTPOa"}],"size":21084,"noattachment":false,"key":"/dir-compare/-/dir-compare-2.2.0.tgz"},"maintainers":[{"name":"gliviu","email":"grigoresculiviu@gmail.com"}],"_npmUser":{"name":"gliviu","email":"grigoresculiviu@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dir-compare_2.2.0_1580605472662_0.21299633562231435"},"_hasShrinkwrap":false,"readme":"dir-compare\n==========\nNode JS directory compare\n\n**Starting with v3.0.0 the CLI utility moved to [dir-compare-cli](https://www.npmjs.com/package/dir-compare-cli).**\n\n[![Build status](https://ci.appveyor.com/api/projects/status/fpnqkr2gfg7pwkxk/branch/master?svg=true)](https://ci.appveyor.com/project/gliviu/dir-compare)\n[![codecov.io](http://codecov.io/github/gliviu/dir-compare/coverage.svg?branch=master)](http://codecov.io/github/gliviu/dir-compare?branch=master)\n\n- [Installation](#installation)\n- [Library](#library)\n  * [Use](#use)\n  * [Api](#api)\n  * [Glob patterns](#glob-patterns)\n  * [Symbolic links](#symbolic-links)\n  * [Handling permission denied errors](#handling-permission-denied-errors)\n- [Extension points](#extension-points)\n  * [File content comparators](#file-content-comparators)\n    + [Ignore line endings and white spaces](#ignore-line-endings-and-white-spaces)\n  * [Glob filter](#glob-filter)\n    + [Implement .gitignore filter](#implement-gitignore-filter)\n  * [Name comparators](#name-comparators)\n  * [Result builder](#result-builder)\n- [UI tools](#ui-tools)\n- [Changelog](#changelog)\n\n# Installation\n```bash\nnpm install dir-compare\n```\n\n# Library\n\n## Use\n```javascript\nconst dircompare = require('dir-compare');\n\nconst options = { compareSize: true };\n// Multiple compare strategy can be used simultaneously - compareSize, compareContent, compareDate, compareSymlink.\n// If one comparison fails for a pair of files, they are considered distinct.\nconst path1 = '...';\nconst path2 = '...';\n\n// Synchronous\nconst res = dircompare.compareSync(path1, path2, options)\nprint(res)\n\n// Asynchronous\ndircompare.compare(path1, path2, options)\n  .then(res => print(res))\n  .catch(error => console.error(error));\n\nfunction print(result) {\n  console.log('Directories are %s', result.same ? 'identical' : 'different')\n\n  console.log('Statistics - equal entries: %s, distinct entries: %s, left only entries: %s, right only entries: %s, differences: %s',\n    result.equal, result.distinct, result.left, result.right, result.differences)\n\n  result.diffSet.forEach(dif => console.log('Difference - path: %s, name1: %s, type1: %s, name2: %s, type2: %s, state: %s',\n    dif.relativePath, dif.name1, dif.type1, dif.name2, dif.type2, dif.state))\n}\n```\n\nTypescript\n```typescript\nimport { compare, compareSync, Options, Result } from \"dir-compare\";\nconst path1 = '...';\nconst path2 = '...';\nconst options: Options = { compareSize: true };\n\nconst res: Result = compareSync(path1, path2, options);\nconsole.log(res)\n\ncompare(path1, path2, options)\n  .then(res => console.log(res))\n  .catch(error => console.error(error));\n```\n\n## Api\n\n```typescript\ncompare(path1: string, path2: string, options?: Options): Promise<Result>\ncompareSync(path1: string, path2: string, options?: Options): Result\n```\nMore details can be found in the reference documentation:\n* [compare](https://gliviu.github.io/dc-api/functions/compare.html)\n* [compareSync](https://gliviu.github.io/dc-api/functions/compareSync.html)\n* [Options](https://gliviu.github.io/dc-api/interfaces/Options.html) \n* [Result](https://gliviu.github.io/dc-api/interfaces/Result.html)\n\nCommon options:\n* [compareSize](https://gliviu.github.io/dc-api/interfaces/Options.html#compareSize)\n* [compareContent](https://gliviu.github.io/dc-api/interfaces/Options.html#compareContent)\n* [compareDate](https://gliviu.github.io/dc-api/interfaces/Options.html#compareDate) \n* [excludeFilter](https://gliviu.github.io/dc-api/interfaces/Options.html#excludeFilter)\n* [includeFilter](https://gliviu.github.io/dc-api/interfaces/Options.html#includeFilter) \n* [ignoreCase](https://gliviu.github.io/dc-api/interfaces/Options.html#ignoreCase) \n* [skipSubdirs](https://gliviu.github.io/dc-api/interfaces/Options.html#skipSubdirs)\n* [skipEmptyDirs](https://gliviu.github.io/dc-api/interfaces/Options.html#skipEmptyDirs)\n\n##  Glob patterns\n[Minimatch](https://www.npmjs.com/package/minimatch) patterns are used to include/exclude files to be compared.\n\nThe pattern is matched against the relative path of the entry being compared.\n\nFollowing examples assume we are comparing two [dir-compare](https://github.com/gliviu/dir-compare) code bases.\n\n```javascript\nconst options = { \n  excludeFilter: \".git,node_modules\",   //  exclude git and node modules directories  \n  excludeFilter: \"expected\"         ,   //  exclude '/tests/expected' directory  \n  excludeFilter: \"/tests/expected\"  ,   //  exclude '/tests/expected' directory  \n  excludeFilter: \"**/expected\"      ,   //  exclude '/tests/expected' directory  \n  excludeFilter: \"**/tests/**/*.js\" ,   //  exclude all js files in '/tests' directory and subdirectories  \n\n  includeFilter: \"*.js,*.yml\"       ,   //  include js and yaml files  \n  includeFilter: \"/tests/**/*.js\"   ,   //  include all js files in '/tests' directory and subdirectories  \n  includeFilter: \"**/tests/**/*.ts\"     //  include all js files in '/tests' directory and subdirectories  \n}\n```\nThis behavior can be changed with [Glob filter extensions](#glob-filter).\n\n\n## Symbolic links\nUnless `compareSymlink` option is used, symbolic links are resolved and any comparison is applied to the file/directory they point to.\n\nCircular loops are handled by breaking the loop as soon as it is detected.\n\nVersion `1.x` treats broken links as `ENOENT: no such file or directory`.  \nSince `2.0` they are treated as a special type of entry - `broken-link` - and are available as stats (`totalBrokenLinks`, `distinctBrokenLinks`, ...).\n\nUsing `compareSymlink` option causes `dircompare` to check symlink values for equality.\nIn this mode two entries with identical names are considered different if\n* one is symlink, the other is not\n* both are symlinks but point to different locations\n\nThese rules are applied in addition to the other comparison modes; ie. by content, by size...\n\nIf entries are different because of symlinks, `reason` will be `different-symlink`. Also statistics summarize differences caused by symbolic links.\n\n## Handling permission denied errors\nUnreadable files or directories are normally reported as errors. The comparison will be interrupted with an `EACCES` exception.\nThis behavior can be altered with [Options.handlePermissionDenied](https://gliviu.github.io/dc-api/interfaces/Options.html#handlePermissionDenied).\n\n# Extension points\n\n## File content comparators\nBy default file content is binary compared. As of version 1.5.0 custom file comparison handlers may be specified.\n\nCustom handlers are specified by `compareFileSync` and `compareFileAsync` options which correspond to `dircompare.compareSync()` or `dircompare.compare()` methods.\n\nA couple of handlers are included in the library:\n* binary sync compare - `dircompare.fileCompareHandlers.defaultFileCompare.compareSync`\n* binary async compare - `dircompare.fileCompareHandlers.defaultFileCompare.compareAsync`\n* text sync compare - `dircompare.fileCompareHandlers.lineBasedFileCompare.compareSync`\n* text async compare - `dircompare.fileCompareHandlers.lineBasedFileCompare.compareAsync`\n\nUse [defaultFileCompare](https://github.com/gliviu/dir-compare/blob/master/src/FileCompareHandler/default/defaultFileCompare.ts) as an example to create your own.\n\n### Ignore line endings and white spaces\nLine based comparator can be used to ignore line ending and white space differences.\n```javascript\nconst dircompare = require('dir-compare');\n\nconst options = {\n  compareContent: true,\n  compareFileSync: dircompare.fileCompareHandlers.lineBasedFileCompare.compareSync,\n  compareFileAsync: dircompare.fileCompareHandlers.lineBasedFileCompare.compareAsync,\n  ignoreLineEnding: true,      // Ignore crlf/lf line ending differences\n  ignoreWhiteSpaces: true,     // Ignore white spaces at the beginning and end of a line (similar to 'diff -b')\n  ignoreAllWhiteSpaces: true,  // Ignore all white space differences (similar to 'diff -w')\n  ignoreEmptyLines: true       // Ignores differences caused by empty lines (similar to 'diff -B')\n};\n\nconst path1 = '...';\nconst path2 = '...';\nconst res = dircompare.compareSync(path1, path2, options);\nconsole.log(res)\n\ndircompare.compare(path1, path2, options)\n.then(res => console.log(res))\n```\n\n## Glob filter\nThe current implementation of the glob filter uses minimatch and is based on [includeFilter and excludeFilter options](#glob-patterns). While it is meant to fit most use cases, [some scenarios](https://github.com/gliviu/dir-compare/issues/67) are not addressed.\n\nUse [filterHandler option](https://gliviu.github.io/dc-api/interfaces/Options.html#filterHandler) to alter this behavior.\n\nThe following example demonstrates how to include only files with a specific extension in our comparison.\n```typescript\nimport { Options, compareSync, Result, FilterHandler, Entry, filterHandlers } from 'dir-compare'\nimport { extname } from 'path'\n\nvar d1 = '...';\nvar d2 = '...';\n\nconst filterByfileExtension: FilterHandler = (entry: Entry, relativePath: string, options: Options): boolean => {\n  if (!options.fileExtension) {\n    // Fallback on the default 'minimatch' implementation\n    return filterHandlers.defaultFilterHandler(entry, relativePath, options)\n  }\n\n  return options.fileExtension === extname(entry.name)\n}\n\nconst options: Options = {\n  compareSize: true,\n  fileExtension: '.txt',\n  filterHandler: filterByfileExtension\n}\n\nconst res: Result = compareSync(d1, d2, options)\n```\n\nFor reference, the default minimatch filter can be found in [defaultFilterHandler](https://github.com/gliviu/dir-compare/blob/master/src/FilterHandler/defaultFilterHandler.ts) which is exposed by [filterHandlers property](https://gliviu.github.io/dc-api/variables/filterHandlers.html).\n\n### Implement .gitignore filter\n[Globby](https://www.npmjs.com/package/globby) library provides the functionality to parse and apply `.gitignore` rules.\nThis is a [sample implementation](https://github.com/gliviu/dir-compare/blob/master/test/extended/gitignoreSupport/gitignoreFilter.ts) that uses globby and dir-compare filter extension.\n\nUsage:\n```typescript\nimport { Options, compareSync, Result} from 'dir-compare'\nimport { getGitignoreFilter } from './gitignoreFilter.js'\n\nvar d1 = '...';\nvar d2 = '...';\n\nconst options: Options = {\n  compareSize: true,\n  filterHandler: getGitignoreFilter(d1, d2),\n  includeFilter: '*.js'  // if present, regular filters are applied after .gitignore rules.\n}\n\nconst res: Result = compareSync(d1, d2, options)\n\n```\n\n## Name comparators\nIf [default](https://github.com/gliviu/dir-compare/blob/master/src/NameCompare/defaultNameCompare.ts) name comparison is not enough, custom behavior can be specified with [compareNameHandler](https://gliviu.github.io/dc-api/interfaces/Options.html#compareNameHandler) option.\nFollowing example adds the possibility to ignore file extensions.\n```typescript\nimport { Options, compare } from 'dir-compare'\nimport path from 'path'\n\nconst options: Options = {\n    compareSize: false,                    // compare only name by disabling size and content criteria\n    compareContent: false,\n    compareNameHandler: customNameCompare, // new name comparator used to ignore extensions\n    ignoreExtension: true,                 // supported by the custom name compare below\n};\n\nfunction customNameCompare(name1: string, name2: string, options: Options) {\n    if (options.ignoreCase) {\n        name1 = name1.toLowerCase()\n        name2 = name2.toLowerCase()\n    }\n    if (options.ignoreExtension) {\n        name1 = path.basename(name1, path.extname(name1))\n        name2 = path.basename(name2, path.extname(name2))\n    }\n    return ((name1 === name2) ? 0 : ((name1 > name2) ? 1 : -1))\n}\n\nconst path1 = '/tmp/a';\nconst path2 = '/tmp/b';\n\nconst res = compare(path1, path2, options).then(res => {\n    console.log(`Same: ${res.same}`)\n    if (!res.diffSet) {\n        return\n    }\n    res.diffSet.forEach(dif => console.log(`${dif.name1} ${dif.name2} ${dif.state}`))\n})\n\n// Outputs\n// icon.svg icon.png equal\n// logo.svg logo.jpg equal\n```\nFor reference, the default name comparator can be found in [defaultNameCompare](https://github.com/gliviu/dir-compare/blob/master/src/NameCompare/defaultNameCompare.ts) which is exposed by [compareNameHandlers property](https://gliviu.github.io/dc-api/variables/compareNameHandlers.html).\n\n\n## Result builder\n[Result builder](https://gliviu.github.io/dc-api/interfaces/Options.html#resultBuilder) is called for each pair of entries encountered during comparison. Its purpose is to append entries in `diffSet` and eventually update `statistics` object with new stats.\n\nIf needed it can be replaced with custom implementation.\n\n```javascript\nconst dircompare = require(\"dircompare\")\n\nconst customResultBuilder = function (entry1, entry2, state, level, relativePath, options, statistics, diffSet, reason) {\n    ...\n}\n\nconst options = {\n    compareSize: true,\n    resultBuilder: customResultBuilder\n}\nconst res = dircompare.compareSync('...', '...', options)\n\n```\n\nThe [default](https://github.com/gliviu/dir-compare/blob/master/src/ResultBuilder/defaultResultBuilderCallback.ts) builder can be used as an example.\n\n# UI tools\n* [dir-compare-cli](https://github.com/gliviu/dir-compare-cli)\n* [Visual Studio Code - Compare Folders](https://marketplace.visualstudio.com/items?itemName=moshfeu.compare-folders)\n\n# Changelog\n* v5.0.0\n  Breaking changes:\n    * `skipSubdirs` option has slightly different behavior. More details in [#77](https://github.com/gliviu/dir-compare/issues/77#issuecomment-2094375352)\n* v4.2.0\n  * Updated dependencies\n  * Increased test coverage\n* v4.1.0\n  * Possibility to alter the default [Glob filter](#glob-filter) behavior\n  * [Ignore files and directories according to .gitignore rules](#implement-gitignore-filter).\n  * New [origin](https://gliviu.github.io/dc-api/interfaces/Entry.html#origin) field in Entry to distinguish between the left or right directory\n  * Improved api documentation\n* v4.0.0\n    * Switched project to typescript\n    * [Async comparator](https://gliviu.github.io/dc-api/functions/compare.html) improvements when comparing large directory structures\n      * Heap usage has decreased 3x compared to previous version\n      * Works 2x faster when comparing by content\n      * Better concurrency. UI apps will be more responsive while comparison is ongoing\n\n  Breaking changes:\n    * Using this library to compare two files will ignore the name of the files. More details in [#48](https://github.com/gliviu/dir-compare/issues/48)\n    * Removed support for node 8, 9\n* v3.3.0 Added `skipEmptyDirs` option\n* v3.2.0 [Handle permission denied errors](#handling-permission-denied-errors)\n* v3.1.0 Added `ignoreAllWhiteSpaces` and `ignoreEmptyLines` options\n* v3.0.0 Moved CLI component into separate project [dir-compare-cli](https://github.com/gliviu/dir-compare-cli)\n* v2.4.0 [New option](https://gliviu.github.io/dc-api/interfaces/Options.html#compareNameHandler) to customize file/folder name comparison\n* v2.3.0 Fixes\n* v2.1.0 Removed [bluebird](https://github.com/petkaantonov/bluebird/#%EF%B8%8Fnote%EF%B8%8F) dependency\n* v2.0.0\n  * New option to compare symlinks.\n  * New field indicating reason for two entries being distinct.\n  * Improved command line output format.\n  * Tests are no longer part of published package.\n  * Generated [Api](https://gliviu.github.io/dc-api) documentation.\n  \n  Breaking changes:\n  * Broken links are no longer treated as errors. As a result there are new statistics (leftBrokenLinks, rightBrokenLinks, distinctBrokenLinks, totalBrokenLinks) and new entry type - broken-link.\n    Details in [Symbolic links](#symbolic-links).\n  * Typescript correction: new interface `Result` replaced `Statistics`.\n* v1.8.0 \n    * globstar patterns\n    * typescript corrections\n    * removed support for node 0.11, 0.12, iojs\n* v1.7.0 performance improvements\n* v1.6.0 typescript support\n* v1.5.0 added option to ignore line endings and white space differences\n* v1.3.0 added date tolerance option\n* v1.2.0 added compare by date option\n* v1.1.0\n    * detect symlink loops\n    * improved color scheme for command line utility\n* v1.0.0\n    * asynchronous comparison\n    * new library options: noDiffSet, resultBuilder\n    * new statistics: distinctFiles, equalFiles, leftFiles, rightFiles, distinctDirs, equalDirs, leftDirs, rightDirs\n    * new --async command line option\n    * Fix for https://github.com/tj/commander.js/issues/125\n* v0.0.3 Fix file ordering issue for newer node versions\n\n","publish_time":1580605472857,"_cnpm_publish_time":1580605472857,"dist-tags":{"latest":"5.0.0"}}