File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -108,10 +108,28 @@ function printPages(pages, singleColumn) {
108
108
function printBestPage ( command , options ) {
109
109
var content = cache . getPage ( command ) ;
110
110
if ( ! content ) {
111
- console . error ( messages . notFound ( ) ) ;
112
- exit ( 1 ) ;
111
+ console . log ( 'Page not found. Updating cache ..' ) ;
112
+ cache . update ( function ( err ) {
113
+ if ( err ) {
114
+ console . error ( err . stack ) ;
115
+ exit ( 1 ) ;
116
+ }
117
+ var content2 = cache . getPage ( command ) ;
118
+ if ( ! content2 ) {
119
+ console . error ( messages . notFound ( ) ) ;
120
+ exit ( 1 ) ;
121
+ } else {
122
+ checkStale ( ) ;
123
+ renderContent ( content2 , options ) ;
124
+ }
125
+ } ) ;
126
+ } else {
127
+ checkStale ( ) ;
128
+ renderContent ( content , options ) ;
113
129
}
114
- checkStale ( ) ;
130
+ }
131
+
132
+ function renderContent ( content , options ) {
115
133
var page = parser . parse ( content ) ;
116
134
if ( options && options . randomExample === true ) {
117
135
page . examples = [ sample ( page . examples ) ] ;
Original file line number Diff line number Diff line change 37
37
"scripts" : {
38
38
"precommit" : " npm run lint && npm run test:quiet" ,
39
39
"prepush" : " npm run test:quiet" ,
40
- "postinstall" : " node ./bin/tldr --update" ,
41
40
"start" : " node ./bin/tldr" ,
42
41
"example" : " node ./bin/tldr tar" ,
43
42
"test" : " mocha test --require=env-test" ,
You can’t perform that action at this time.
0 commit comments