Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dir-compare

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dir-compare - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

tests/expected/test010_0.txt

8

compareAsync.js

@@ -145,7 +145,7 @@ var fs = require('fs');

if(type1==='file'){
var compareSize = options.compareSize === undefined ? false : options.compareSize;
var compareContent = options.compareContent === undefined ? false : options.compareContent;
if (compareSize && fileStat1.size !== fileStat2.size) {
if (options.compareSize && fileStat1.size !== fileStat2.size) {
same = false;
} else if(compareContent){
} else if(options.compareDate && fileStat1.mtime.getTime() !== fileStat2.mtime.getTime()){
same = false;
} else if(options.compareContent){
var cmpFile = function(entry1, entry2, type1, type2){

@@ -152,0 +152,0 @@ var subDiffSet;

@@ -117,7 +117,7 @@ var fs = require('fs');

if(type1==='file'){
var compareSize = options.compareSize === undefined ? false : options.compareSize;
var compareContent = options.compareContent === undefined ? false : options.compareContent;
if (compareSize && fileStat1.size !== fileStat2.size) {
if (options.compareSize && fileStat1.size !== fileStat2.size) {
same = false;
} else if(compareContent){
} else if(options.compareDate && fileStat1.mtime.getTime() !== fileStat2.mtime.getTime()){
same = false;
} else if(options.compareContent){
same = options.compareFileSync(p1, fileStat1, p2, fileStat2, options);

@@ -124,0 +124,0 @@ } else{

@@ -16,2 +16,3 @@ #!/usr/bin/env node

.option('-c, --compare-content', 'compare files by content')
.option('-D, --compare-date', 'compare files by date')
.option('-f, --filter [type]', 'file name filter', undefined)

@@ -67,2 +68,3 @@ .option('-x, --exclude [type]', 'file/directory name exclude filter', undefined)

options.compareContent = program.compareContent;
options.compareDate = program.compareDate;
options.compareSize = true;

@@ -69,0 +71,0 @@ options.skipSubdirs = program.skipSubdirs;

@@ -124,2 +124,3 @@ var util = require('util');

* compareSize: true/false - Compares files by size. Defaults to 'false'.
* compareDate: true/false - Compares files by date of modification (stat.mtime). Defaults to 'false'.
* compareContent: true/false - Compares files by content. Defaults to 'false'.

@@ -163,4 +164,4 @@ * skipSubdirs: true/false - Skips sub directories. Defaults to 'false'.

* size2: file size
* date1: modification date (stat.mdate)
* date2: modification date (stat.mdate)
* date1: modification date (stat.mtime)
* date2: modification date (stat.mtime)
* level: depth

@@ -167,0 +168,0 @@ */

{
"name": "dir-compare",
"version": "1.1.0",
"version": "1.2.0",
"description": "Node JS directory compare",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -77,2 +77,3 @@ dir-compare

* compareSize: true/false - Compares files by size. Defaults to 'false'.
* compareDate: true/false - Compares files by date of modification (stat.mtime). Defaults to 'false'.
* compareContent: true/false - Compares files by content. Defaults to 'false'.

@@ -116,4 +117,4 @@ * skipSubdirs: true/false - Skips sub directories. Defaults to 'false'.

* size2: file size
* date1: modification date (stat.mdate)
* date2: modification date (stat.mdate)
* date1: modification date (stat.mtime)
* date2: modification date (stat.mtime)
* level: depth

@@ -131,2 +132,3 @@

-c, --compare-content compare files by content
-D, --compare-date compare files by date
-f, --filter [type] file name filter

@@ -162,2 +164,4 @@ -x, --exclude [type] file/directory name exclude filter

## Changelog
* v1.2.0
* added compare by date option
* v1.1.0

@@ -164,0 +168,0 @@ * detect symlink loops

@@ -510,10 +510,50 @@ "use strict";

},
////////////////////////////////////////////////////
// Compare date //
////////////////////////////////////////////////////
{
name: 'test010_0', path1: 'd31', path2: 'd32',
options: {compareSize: true, compareDate: false},
displayOptions: {showAll: true, wholeReport: true, nocolors: true},
commandLineOptions: '-aw',
exitCode: 0,
},
{
name: 'test010_1', path1: 'd31', path2: 'd32',
options: {compareSize: true, compareDate: true},
displayOptions: {showAll: true, wholeReport: true, nocolors: true},
commandLineOptions: '-awD',
exitCode: 1,
},
{
name: 'test010_2', path1: 'd31', path2: 'd32',
options: {compareSize: true, compareDate: false, compareContent: true},
displayOptions: {showAll: true, wholeReport: true, nocolors: true},
commandLineOptions: '-awc',
exitCode: 1,
},
{
name: 'test010_3', path1: 'd31', path2: 'd32',
options: {compareSize: true, compareDate: true, compareContent: true},
displayOptions: {showAll: true, wholeReport: true, nocolors: true},
commandLineOptions: '-awcD',
exitCode: 1,
},
];
//Matches date (ie 2014-11-18T21:32:39.000Z)
function normalize (str) {
str = normalizeDate(str);
str = normalizeLineEnding(str);
return str;
}
var normalizeDateRegexp = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z/gm;
function normalize (str) {
function normalizeDate (str) {
// replace date
return str.replace(normalizeDateRegexp, 'x');
}
var normalizeLineEndingRegexp = /\r\n/g;
function normalizeLineEnding (str) {
return str.replace(normalizeLineEndingRegexp, '\n');
}

@@ -590,3 +630,3 @@ var checkStatistics = function(statistics, test){

if (test.name == 'test005_5x') {
if (test.name == 'test001_1') {
console.log(output);

@@ -596,3 +636,2 @@ console.log(expected);

console.log(output === expected);
}

@@ -665,5 +704,2 @@ var statisticsCheck = checkStatistics(result, test);

var res;
if (test.name == 'test002_3x') {
console.log(output);
}
if(expectedExitCode===2){

@@ -676,2 +712,6 @@ // output not relevant for error codes

}
if (test.name == 'test010_1x') {
console.log(output);
console.log(expectedOutput);
}
var testDescription = 'command line ' + (async?'async':'sync');

@@ -678,0 +718,0 @@ report(test.name, testDescription, output, exitCode, res, saveReport);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc