summaryrefslogtreecommitdiff
path: root/node_modules/dir-compare/src/statistics/statisticsUpdate.js
diff options
context:
space:
mode:
authorLinuxWizard42 <computerwizard@linuxmail.org>2022-10-12 22:54:37 +0300
committerLinuxWizard42 <computerwizard@linuxmail.org>2022-10-12 22:54:37 +0300
commit703e03aba33f234712206769f57717ba7d92d23d (patch)
tree0041f04ccb75bd5379c764e9fe42249fffe75fc3 /node_modules/dir-compare/src/statistics/statisticsUpdate.js
parentab6e257e6e9d9a483d7e86f220d8b209a2cd7753 (diff)
downloadFlashRunner-703e03aba33f234712206769f57717ba7d92d23d.tar.gz
FlashRunner-703e03aba33f234712206769f57717ba7d92d23d.tar.zst
Added export_allowed file to make repository visible in cgit
Diffstat (limited to 'node_modules/dir-compare/src/statistics/statisticsUpdate.js')
-rw-r--r--node_modules/dir-compare/src/statistics/statisticsUpdate.js62
1 files changed, 62 insertions, 0 deletions
diff --git a/node_modules/dir-compare/src/statistics/statisticsUpdate.js b/node_modules/dir-compare/src/statistics/statisticsUpdate.js
new file mode 100644
index 0000000..a1b2312
--- /dev/null
+++ b/node_modules/dir-compare/src/statistics/statisticsUpdate.js
@@ -0,0 +1,62 @@
+/**
+ * Calculates comparison statistics.
+ */
+module.exports = {
+ updateStatisticsBoth: function (entry1, entry2, same, reason, type, statistics, options) {
+ same ? statistics.equal++ : statistics.distinct++
+ if (type === 'file') {
+ same ? statistics.equalFiles++ : statistics.distinctFiles++
+ } else if (type === 'directory') {
+ same ? statistics.equalDirs++ : statistics.distinctDirs++
+ } else if (type === 'broken-link') {
+ statistics.brokenLinks.distinctBrokenLinks++
+ } else {
+ throw new Error('Unexpected type ' + type)
+ }
+
+ var isSymlink1 = entry1 ? entry1.isSymlink : false
+ var isSymlink2 = entry2 ? entry2.isSymlink : false
+ var isSymlink = isSymlink1 || isSymlink2
+ if (options.compareSymlink && isSymlink) {
+ var symlinks = statistics.symlinks
+ if (reason === 'different-symlink') {
+ symlinks.distinctSymlinks++
+ } else {
+ symlinks.equalSymlinks++
+ }
+ }
+
+ },
+ updateStatisticsLeft: function (entry1, type, statistics, options) {
+ statistics.left++
+ if (type === 'file') {
+ statistics.leftFiles++
+ } else if (type === 'directory') {
+ statistics.leftDirs++
+ } else if (type === 'broken-link') {
+ statistics.brokenLinks.leftBrokenLinks++
+ } else {
+ throw new Error('Unexpected type ' + type)
+ }
+
+ if (options.compareSymlink && entry1.isSymlink) {
+ statistics.symlinks.leftSymlinks++
+ }
+ },
+ updateStatisticsRight: function (entry2, type, statistics, options) {
+ statistics.right++
+ if (type === 'file') {
+ statistics.rightFiles++
+ } else if (type === 'directory') {
+ statistics.rightDirs++
+ } else if (type === 'broken-link') {
+ statistics.brokenLinks.rightBrokenLinks++
+ } else {
+ throw new Error('Unexpected type ' + type)
+ }
+
+ if (options.compareSymlink && entry2.isSymlink) {
+ statistics.symlinks.rightSymlinks++
+ }
+ },
+} \ No newline at end of file