| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent da1e13f commit 607173b
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,8 @@ args.forEach(function(arg) { | |||
| 24 | 24 | } | |
| 25 | 25 | }); | |
| 26 | 26 | ||
| 27 | + nodeVersion = nodeVersion || process.version; | ||
| 28 | + | ||
| 27 | 29 | if (!inputFile) { | |
| 28 | 30 | throw new Error('No input file specified'); | |
| 29 | 31 | } | |
@@ -46,15 +48,11 @@ function next(er, input) { | |||
| 46 | 48 | break; | |
| 47 | 49 | ||
| 48 | 50 | case 'html': | |
| 49 | - require('./html.js')({ | ||
| 50 | - input: input, | ||
| 51 | - filename: inputFile, | ||
| 52 | - template: template, | ||
| 53 | - nodeVersion: nodeVersion, | ||
| 54 | - }, function(er, html) { | ||
| 55 | - if (er) throw er; | ||
| 56 | - console.log(html); | ||
| 57 | - }); | ||
| 51 | + require('./html.js')(input, inputFile, template, nodeVersion, | ||
| 52 | + function(er, html) { | ||
| 53 | + if (er) throw er; | ||
| 54 | + console.log(html); | ||
| 55 | + }); | ||
| 58 | 56 | break; | |
| 59 | 57 | ||
| 60 | 58 | default: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,11 +30,12 @@ var gtocPath = path.resolve(path.join( | |||
| 30 | 30 | var gtocLoading = null; | |
| 31 | 31 | var gtocData = null; | |
| 32 | 32 | ||
| 33 | - /** | ||
| 34 | - * opts: input, filename, template, nodeVersion. | ||
| 35 | - */ | ||
| 36 | - function toHTML(opts, cb) { | ||
| 37 | - var template = opts.template; | ||
| 33 | + function toHTML(input, filename, template, nodeVersion, cb) { | ||
| 34 | + if (typeof nodeVersion === 'function') { | ||
| 35 | + cb = nodeVersion; | ||
| 36 | + nodeVersion = null; | ||
| 37 | + } | ||
| 38 | + nodeVersion = nodeVersion || process.version; | ||
| 38 | 39 | ||
| 39 | 40 | if (gtocData) { | |
| 40 | 41 | return onGtocLoaded(); | |
@@ -56,15 +57,10 @@ function toHTML(opts, cb) { | |||
| 56 | 57 | } | |
| 57 | 58 | ||
| 58 | 59 | function onGtocLoaded() { | |
| 59 | - var lexed = marked.lexer(opts.input); | ||
| 60 | + var lexed = marked.lexer(input); | ||
| 60 | 61 | fs.readFile(template, 'utf8', function(er, template) { | |
| 61 | 62 | if (er) return cb(er); | |
| 62 | - render({ | ||
| 63 | - lexed: lexed, | ||
| 64 | - filename: opts.filename, | ||
| 65 | - template: template, | ||
| 66 | - nodeVersion: opts.nodeVersion, | ||
| 67 | - }, cb); | ||
| 63 | + render(lexed, filename, template, nodeVersion, cb); | ||
| 68 | 64 | }); | |
| 69 | 65 | } | |
| 70 | 66 | } | |
@@ -91,13 +87,13 @@ function toID(filename) { | |||
| 91 | 87 | .replace(/-+/g, '-'); | |
| 92 | 88 | } | |
| 93 | 89 | ||
| 94 | - /** | ||
| 95 | - * opts: lexed, filename, template, nodeVersion. | ||
| 96 | - */ | ||
| 97 | - function render(opts, cb) { | ||
| 98 | - var lexed = opts.lexed; | ||
| 99 | - var filename = opts.filename; | ||
| 100 | - var template = opts.template; | ||
| 90 | + function render(lexed, filename, template, nodeVersion, cb) { | ||
| 91 | + if (typeof nodeVersion === 'function') { | ||
| 92 | + cb = nodeVersion; | ||
| 93 | + nodeVersion = null; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + nodeVersion = nodeVersion || process.version; | ||
| 101 | 97 | ||
| 102 | 98 | // get the section | |
| 103 | 99 | var section = getSection(lexed); | |
@@ -117,7 +113,7 @@ function render(opts, cb) { | |||
| 117 | 113 | template = template.replace(/__ID__/g, id); | |
| 118 | 114 | template = template.replace(/__FILENAME__/g, filename); | |
| 119 | 115 | template = template.replace(/__SECTION__/g, section); | |
| 120 | - template = template.replace(/__VERSION__/g, opts.nodeVersion); | ||
| 116 | + template = template.replace(/__VERSION__/g, nodeVersion); | ||
| 121 | 117 | template = template.replace(/__TOC__/g, toc); | |
| 122 | 118 | template = template.replace( | |
| 123 | 119 | /__GTOC__/g, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments