-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbatch-loader.js
49 lines (44 loc) · 1.15 KB
/
batch-loader.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
var config = require('./config.json');
var fs = require('fs');
var Promise = require('bluebird');
var parseString = Promise.promisify(require('xml2js').parseString);
var uuid = require('node-uuid');
var feeds = require('./feeds');
var tasks = [];
var xml = fs.readFileSync(process.argv[2], 'utf8');
feeds.loadEntries(xml).then(function() {
process.exit();
}).catch(function(err) {
console.error(err.stack);
process.exit();
});
/*
for (var i = 2; i < process.argv.length; i += 2) {
var title = process.argv[i];
var filename = process.argv[i + 1];
var xml = fs.readFileSync(filename, 'utf8');
var task = parseString(xml).then(function(doc) {
var feed = {
uuid: filename,
title: title,
updated: new Date(),
author: '',
content: '',
doc: doc
};
return feeds.save(feed)
}).then(function() {
console.log('Loaded "%s"', filename);
}).catch(function(err) {
console.error('An error occured while loading "%s"', filename);
console.error(err);
});
tasks.push(task);
}
Promise.all(entries).then(function() {
process.exit();
}).catch(function(err) {
console.error(err.stack);
process.exit();
});
*/