Skip to content

Commit 4422ce7

Browse files
committed
Removing postinstall step
- This was a source of errors for a long time. Now, we update the cache on a page fetch miss.
1 parent f1ec26f commit 4422ce7

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

lib/tldr.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,28 @@ function printPages(pages, singleColumn) {
108108
function printBestPage(command, options) {
109109
var content = cache.getPage(command);
110110
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);
113129
}
114-
checkStale();
130+
}
131+
132+
function renderContent(content, options) {
115133
var page = parser.parse(content);
116134
if (options && options.randomExample === true) {
117135
page.examples = [sample(page.examples)];

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"scripts": {
3838
"precommit": "npm run lint && npm run test:quiet",
3939
"prepush": "npm run test:quiet",
40-
"postinstall": "node ./bin/tldr --update",
4140
"start": "node ./bin/tldr",
4241
"example": "node ./bin/tldr tar",
4342
"test": "mocha test --require=env-test",

0 commit comments

Comments
 (0)