Skip to content

Commit 61d897a

Browse files
committed
Fixing the --render option
The promisified version of index.getShortIndex() was not used.
1 parent d87122d commit 61d897a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/tldr.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,20 @@ exports.randomExample = () => {
5656
};
5757

5858
exports.render = (file) => {
59-
// Reading the file
6059
fs.readFile(file, 'utf8', (err, content) => {
6160
if (err) {
6261
console.error(err);
6362
exit(1);
6463
}
6564
// Getting the shortindex first to populate the shortindex var
66-
index.getShortIndex(() => {
67-
renderContent(content);
68-
});
65+
index.getShortIndex()
66+
.then(() => {
67+
renderContent(content);
68+
})
69+
.catch((err) => {
70+
console.error(err);
71+
exit(1);
72+
});
6973
});
7074
};
7175

@@ -166,7 +170,7 @@ function printBestPage(command, options={}) {
166170
});
167171
}
168172

169-
function renderContent(content, options) {
173+
function renderContent(content, options={}) {
170174
if (options.markdown) {
171175
return console.log(content);
172176
}

0 commit comments

Comments
 (0)