summaryrefslogtreecommitdiff
path: root/node_modules/dir-compare/src/entry/entryComparator.js
blob: d0361f56503d34d02fc1bd61a2bc70a013667947 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
 * Determines order criteria for sorting entries in a directory.
 */
module.exports = {
	compareEntry: function (a, b, options) {
		if (a.isBrokenLink && b.isBrokenLink) {
			return options.compareNameHandler(a.name, b.name, options)
		} else if (a.isBrokenLink) {
			return -1
		} else if (b.isBrokenLink) {
			return 1
		} else if (a.stat.isDirectory() && b.stat.isFile()) {
			return -1
		} else if (a.stat.isFile() && b.stat.isDirectory()) {
			return 1
		} else {
			return options.compareNameHandler(a.name, b.name, options)
		}
	}
}