Created
October 14, 2015 18:19
-
-
Save StreetStrider/0122015d222a7d0d4863 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var | |
exec = require('child_process').exec, | |
path = require('path'); | |
var | |
is_reverse = ~ process.argv.indexOf('reverse'); | |
sync = require('./sync.list'), | |
LEFT_PREFIX = '~', | |
RIGHT_PREFIX = '~/Dropbox'; | |
function compare (list) | |
{ | |
var | |
pair = head(list), | |
left = path.join(LEFT_PREFIX, pair[0]), | |
right = path.join(RIGHT_PREFIX, pair[1]); | |
if (is_reverse) | |
{ | |
var swap = left; | |
left = right; | |
right = swap; | |
} | |
console.log('Comparing:'); | |
console.log('*', left); | |
console.log('*', right); | |
differs(left, right, function (r) | |
{ | |
console.log('>', r ? 'differs' : 'identical'); | |
if (r) | |
{ | |
var command = 'meld '+ left +' '+ right; | |
exec(command, proceed); | |
} | |
else proceed(); | |
function proceed () | |
{ | |
if (list.length) | |
{ | |
compare(list); | |
} | |
} | |
}); | |
}; | |
function head (list) | |
{ | |
return list.shift(); | |
}; | |
function differs (f1, f2, callback) | |
{ | |
var command = 'diff -q '+ f1 +' '+ f2; | |
exec(command, function (ret) | |
{ | |
callback(ret != null); | |
}); | |
} | |
compare(sync); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment