Skip to content

Commit be87030

Browse files
MDecker-MobileComputingmarchersimonMasterOdin
authoredNov 2, 2021
Skip update when page not found (#364)
* New configuration option "skipUpdateWhenPageNotFound". * Mentioning config variable "skipUpdateWhenPageNotFound" in README. * README.md: fixed two JSON fragments. * README: improved one sentence. * Update README.md Co-authored-by: marchersimon <50295997+marchersimon@users.noreply.github.com> * README.md: removed blank in front of ":" in JSON fragment. * Removed log message "Skipping update of cache because option skipUpdateWhenPageNotFound is set". * Update README.md: changes description for `skipUpdateWhenPageNotFound` Co-authored-by: Matthew Peveler <matt.peveler@gmail.com> * Update lib/tldr.js: extended comment Co-authored-by: Matthew Peveler <matt.peveler@gmail.com> * Update tldr.js Co-authored-by: marchersimon <50295997+marchersimon@users.noreply.github.com> Co-authored-by: Matthew Peveler <matt.peveler@gmail.com>
1 parent 1641dea commit be87030

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed
 

‎README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,16 @@ As a contributor, you can also point to your own fork containing the `tldr.zip`
9898

9999
```js
100100
{
101-
"repository" : "http://myrepo/assets/tldr.zip",
101+
"repository": "http://myrepo/assets/tldr.zip"
102+
}
103+
```
104+
105+
By default, a cache update is performed anytime a page is not found for a command. To prevent this behavior,
106+
you can set the configuration variable `skipUpdateWhenPageNotFound` to `true` (defaults to `false`):
107+
108+
```js
109+
{
110+
"skipUpdateWhenPageNotFound": true
102111
}
103112
```
104113

‎config.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"pagesRepository": "https://github.com/tldr-pages/tldr",
33
"repository": "https://tldr.sh/assets/tldr.zip",
4+
"skipUpdateWhenPageNotFound": false,
45
"themes": {
56
"simple": {
67
"commandName": "bold, underline",

‎lib/tldr.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ class Tldr {
129129
.then((content) => {
130130
// If found in first try, render it
131131
if (!content) {
132-
// If not found, try to update
132+
// If not found, try to update cache unless user explicitly wants to skip
133+
if (this.config.skipUpdateWhenPageNotFound === true) {
134+
return '';
135+
}
133136
return spinningPromise('Page not found. Updating cache...', () => {
134137
return this.cache.update();
135138
})

0 commit comments

Comments
 (0)