-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (31 loc) · 934 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
var tar = require('./lib/tar');
var path = require('path');
exports.summary = 'Create/extract a tarball';
exports.usage = '<src> [options]';
exports.options = {
"dest" : {
alias : 'd'
,describe : 'target pack file path'
},
"action": {
alias : 'a'
,default: 'create'
,describe : 'create or extract'
}
};
exports.run = function (options, done) {
var source = options.src;
var target = options.dest;
var action = options.action;
exports[action](source, target, done);
};
exports.create = function(source, target, done){
if(!target && exports.file.findPackageJSON(source)){
var cfg = exports.file.readPackageJSON(source);
target = cfg.name + '-' + cfg.version + '.tar.gz';
}
tar.create(source, target, cfg, exports, done);
};
exports.extract = function(source, target, done) {
tar.extract(source, target, exports, done);
};