-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
executable file
·53 lines (43 loc) · 1.37 KB
/
main.js
File metadata and controls
executable file
·53 lines (43 loc) · 1.37 KB
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
#!/usr/bin/env node
var util = require('util');
var fs = require('fs');
var colors = require('colors');
var args = require('yargs').argv;
require('stringformat').extendString();
var config = require('./config');
var ModelMetadata = require('./ModelMetadata');
var ModelMaker = require('./ModelMaker');
var exitWithError = function(msg,status){
if( typeof(status)==='undefined' ) status = 1;
process.stderr.write(msg+"\n");
process.exit(status);
}
if( fs.existsSync(config.privateConfig) ){
var privateConfig = require(config.privateConfig);
config = util._extend(config,privateConfig);
}
else {
exitWithError("private config file {0} not found".format(config.privateConfig));
}
if( args._.length == 0 && args.w ){
console.log('watch directory');
var modelMaker = ModelMaker(config);
var modelMetadata = ModelMetadata(config);
modelMaker.enableEmail();
modelMetadata.watch(args.w);
modelMaker.watch(args.w);
}
else if( args._.length == 1 ){
var modelMaker = ModelMaker(config);
modelMaker.on("fileFail",function(e){
exitWithError("File processing failure \n{0}".format(e.toString()));
});
modelMaker.process(args._[0]);
}
else {
exitWithError([
"missing arguments",
"usage: main.js {process_dir} - uploads models located in provided directory ",
"usage: main.js -w {watch_dir} - watch the following directory and upload model files added there"
].join('\n').red);
}