Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Skip update when page not found #364

Merged
merged 11 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,16 @@ As a contributor, you can also point to your own fork containing the `tldr.zip`

```js
{
"repository" : "http://myrepo/assets/tldr.zip",
"repository": "http://myrepo/assets/tldr.zip"
}
```

If you want to prevent that a cache update is performed each time no page is found for a command, then
you can set the configuration variable `skipUpdateWhenPageNotFound` to `true` (defaults to `false`):

```js
{
"skipUpdateWhenPageNotFound": true
}
```

Expand Down
1 change: 1 addition & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"pagesRepository": "https://github.com/tldr-pages/tldr",
"repository": "https://tldr.sh/assets/tldr.zip",
"skipUpdateWhenPageNotFound": false,
"themes": {
"simple": {
"commandName": "bold, underline",
Expand Down
3 changes: 3 additions & 0 deletions lib/tldr.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ class Tldr {
// If found in first try, render it
if (!content) {
// If not found, try to update
if (this.config.skipUpdateWhenPageNotFound === true) {
return '';
}
return spinningPromise('Page not found. Updating cache...', () => {
return this.cache.update();
})
Expand Down