Skip to content

Commit 1788753

Browse files
committed
Fixed documentation about pointing to a custom repo
The code just needed the url for the zip file. But it redundantly used 2 settings. The repository and a url attribute. We only need the url. The repository was just used to get the name of the underlying folder which was unecessary anyways. Therefore, named the repository to point to the actual url. Code also got cleaned up in this process. Also updated few dependencies
1 parent 80c740a commit 1788753

File tree

5 files changed

+10
-33
lines changed

5 files changed

+10
-33
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,11 @@ The default platform value can be overwritten with command-line option:
9595
tldr du --os=osx
9696
```
9797

98-
As a contributor, you can also point to your own fork or branch:
98+
As a contributor, you can also point to your own fork containing the `tldr.zip` file. The file is just a zipped version of the entire tldr repo:
9999

100100
```js
101101
{
102-
"repository" : "myfork/tldr",
103-
// or
104-
"repository" : "myfork/tldr#mybranch",
102+
"repository" : "http://myrepo/assets/tldr.zip",
105103
}
106104
```
107105

config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
2-
"pagesRepository": "tldr-pages/tldr",
3-
"url": "http://tldr-pages.github.io/assets/tldr.zip",
2+
"repository": "http://tldr-pages.github.io/assets/tldr.zip",
43
"themes": {
54
"simple": {
65
"commandName": "bold, underline",

lib/cache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ exports.update = (done) => {
4141
return done(err);
4242
}
4343
// Copying from tmp to cache folder
44-
fs.copy(tempFolder, CACHE_FOLDER, {clobber: true}, (err) => {
44+
fs.copy(tempFolder, CACHE_FOLDER, (err) => {
4545
if (err) {
4646
return done(err);
4747
}

lib/remote.js

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,26 @@ const os = require('os');
55
const fs = require('fs-extra');
66
const config = require('./config');
77

8-
function source() {
9-
let repository = config.get().repository;
10-
if (repository) {
11-
let parts = repository.split('#');
12-
let github = parts[0].match(/^(.*)\/(.*)$/);
13-
return {
14-
user: github[1],
15-
repo: github[2],
16-
branch: parts[1] || 'master'
17-
};
18-
}
19-
return null;
20-
}
21-
228
// Downloads the zip file from github and extracts it to /tmp/tldr
239
exports.download = (done) => {
2410
let request = require('request');
2511
let unzip = require('unzip2');
26-
let src = source();
27-
let url = config.get().url;
12+
let url = config.get().repository;
2813
let target = path.join(os.tmpdir(), 'tldr');
29-
let inside = target;
30-
if (src) {
31-
url = 'https://github.com/' + src.user + '/' + src.repo + '/archive/' + src.branch + '.zip';
32-
inside = path.join(target, src.repo + '-' + src.branch);
33-
}
3414

3515
// Empty the tmp dir
3616
fs.emptyDir(target, (err) => {
3717
if (err) {
38-
return done(err, inside);
18+
return done(err, null);
3919
}
4020

4121
// Creating the extractor
4222
let extractor = unzip.Extract({path: target});
4323
extractor.on('error', () => {
44-
done(new Error('Cannot update from ' + url), inside);
24+
done(new Error('Cannot update from ' + url), null);
4525
});
4626
extractor.on('close', () => {
47-
done(null, inside);
27+
done(null, target);
4828
});
4929

5030
// Setting the proxy if set by config

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
"test:all": "npm run lint && npm test && npm run test:functional"
4848
},
4949
"dependencies": {
50-
"chalk": "~1.1.1",
50+
"chalk": "~2.3.0",
5151
"commander": "~2.9.0",
52-
"fs-extra": "^0.30.0",
52+
"fs-extra": "^4.0.2",
5353
"lodash.defaults": "~4.2.0",
5454
"lodash.get": "~4.4.2",
5555
"lodash.identity": "~3.0.0",

0 commit comments

Comments
 (0)