-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
44 lines (37 loc) · 977 Bytes
/
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
/* eslint-disable consistent-return, comma-dangle */
const _ = require('lodash');
const async = require('async');
const rmrf = require('rimraf');
const processSco = require('./lib/processSco.js');
const parseManifestXml = require('./lib/parseManifestXml.js');
const readManifestXml = require('./lib/readManifestXml.js');
const unpackScoZip = require('./lib/unpackScoZip.js');
function scoParser(params) {
const p = params || {};
function validate(cb) {
async.series({
unpackScoZip: _.curry(unpackScoZip)(p),
manifest: _.curry(readManifestXml)(p)
}, (err, result) => {
if (err) cb(err);
cb(null, result.manifest);
});
}
function parse(cb) {
parseManifestXml(p, cb);
}
function process(cb) {
processSco(p, cb);
}
function destroy(cb) {
if (!p.pathToExtractZip) return cb();
rmrf(p.pathToExtractZip, cb);
}
return {
validate,
parse,
process,
destroy
};
}
module.exports = scoParser;