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 all 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"
}
```

By default, a cache update is performed anytime a page is not found for a command. To prevent this behavior,
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
5 changes: 4 additions & 1 deletion lib/tldr.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ class Tldr {
.then((content) => {
// If found in first try, render it
if (!content) {
// If not found, try to update
// If not found, try to update cache unless user explicitly wants to skip
if (this.config.skipUpdateWhenPageNotFound === true) {
return '';
}
return spinningPromise('Page not found. Updating cache...', () => {
return this.cache.update();
})
Expand Down