File tree Expand file tree Collapse file tree 2 files changed +19
-10
lines changed Expand file tree Collapse file tree 2 files changed +19
-10
lines changed Original file line number Diff line number Diff line change 1
1
{
2
- "repository" : " tldr-pages/tldr" ,
3
2
"colors" : {
4
3
"text" : " green" ,
5
4
"command-background" : " black" ,
Original file line number Diff line number Diff line change @@ -19,14 +19,21 @@ exports.download = function(done) {
19
19
var src = source ( ) ;
20
20
var url = 'http://tldr-pages.github.io/assets/tldr.zip' ;
21
21
var target = path . join ( os . tmpdir ( ) , 'tldr' ) ;
22
+ var inside = target ;
23
+ if ( src ) {
24
+ url = 'https://github.com/' + src . user + '/' + src . repo + '/archive/' + src . branch + '.zip' ;
25
+ inside = path . join ( target , src . repo + '-' + src . branch ) ;
26
+ }
22
27
23
28
rimraf . sync ( target ) ;
24
29
mkdirp . sync ( target ) ;
25
30
26
31
var extractor = unzip . Extract ( { path : target } ) ;
27
- extractor . on ( 'error' , done ) ;
32
+ extractor . on ( 'error' , function ( e ) {
33
+ done ( new Error ( 'Cannot update from ' + url ) , inside ) ;
34
+ } ) ;
28
35
extractor . on ( 'close' , function ( ) {
29
- done ( null , target ) ;
36
+ done ( null , inside ) ;
30
37
} ) ;
31
38
32
39
var req = request . get ( {
@@ -39,11 +46,14 @@ exports.download = function(done) {
39
46
}
40
47
41
48
function source ( ) {
42
- var parts = config . get ( ) . repository . split ( '#' ) ;
43
- var github = parts [ 0 ] . match ( / ^ ( .* ) \/ ( .* ) $ / ) ;
44
- return {
45
- user : github [ 1 ] ,
46
- repo : github [ 2 ] ,
47
- branch : parts [ 1 ] || 'master'
48
- } ;
49
+ var repository = config . get ( ) . repository ;
50
+ if ( repository ) {
51
+ var parts = repository . split ( '#' ) ;
52
+ var github = parts [ 0 ] . match ( / ^ ( .* ) \/ ( .* ) $ / ) ;
53
+ return {
54
+ user : github [ 1 ] ,
55
+ repo : github [ 2 ] ,
56
+ branch : parts [ 1 ] || 'master'
57
+ } ;
58
+ }
49
59
}
You can’t perform that action at this time.
0 commit comments