forked from appnexus/sicksync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·58 lines (48 loc) · 1.57 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#! /usr/bin/env node
/**
* Sick Sync
*
* Entry point for the syncin' script. This will run
* EVERYTIME a sync is kicked off.
*/
var fs = require('fs-extra'),
program = require('commander'),
util = require('./lib/util'),
package = require('./package.json'),
bigSync = require('./lib/big-sync'),
configPath = util.getConfigPath(),
hasSetup = fs.existsSync(configPath),
config = null;
require('colors');
program
.version(package.version)
.option('-s, --setup', 'Runs the sicksync setup wizard (happens automatically the first time)')
.option('-d, --debug <boolean>', 'Turns on debug messages during sicksyncs', util.toBoolean)
.option('-e, --encrypt <boolean>', 'Turns on encryption for sicksync messages', util.toBoolean)
.option('-c, --config', 'Opens the config file in your chosen editor')
.option('-o, --Once', 'Runs a one-time sync')
.parse(process.argv);
if (program.setup || !hasSetup) {
return require('./bin/setup.js');
}
if (hasSetup) {
config = require(configPath);
if (typeof program.encrypt !== 'undefined') {
config.prefersEncrypted = program.encrypt;
return util.writeConfig(config);
}
if (typeof program.debug !== 'undefined') {
config.debug = program.debug;
return util.writeConfig(config);
}
if (program.config) {
return util.open(configPath);
}
if (program.Once) {
console.log('Syncing...');
return bigSync(function() {
console.log('Finished!'.green);
});
}
return require('./bin/local.js');
}