| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c8247a7 commit 5247ab3
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,13 +30,13 @@ const fs = require('fs'); | |||
| 30 | 30 | const args = process.argv.slice(2); | |
| 31 | 31 | let format = 'json'; | |
| 32 | 32 | let template = null; | |
| 33 | - let inputFile = null; | ||
| 33 | + let filename = null; | ||
| 34 | 34 | let nodeVersion = null; | |
| 35 | 35 | let analytics = null; | |
| 36 | 36 | ||
| 37 | 37 | args.forEach(function(arg) { | |
| 38 | 38 | if (!arg.startsWith('--')) { | |
| 39 | - inputFile = arg; | ||
| 39 | + filename = arg; | ||
| 40 | 40 | } else if (arg.startsWith('--format=')) { | |
| 41 | 41 | format = arg.replace(/^--format=/, ''); | |
| 42 | 42 | } else if (arg.startsWith('--template=')) { | |
@@ -50,41 +50,32 @@ args.forEach(function(arg) { | |||
| 50 | 50 | ||
| 51 | 51 | nodeVersion = nodeVersion || process.version; | |
| 52 | 52 | ||
| 53 | - if (!inputFile) { | ||
| 53 | + if (!filename) { | ||
| 54 | 54 | throw new Error('No input file specified'); | |
| 55 | 55 | } | |
| 56 | 56 | ||
| 57 | - fs.readFile(inputFile, 'utf8', function(er, input) { | ||
| 57 | + fs.readFile(filename, 'utf8', (er, input) => { | ||
| 58 | 58 | if (er) throw er; | |
| 59 | 59 | // process the input for @include lines | |
| 60 | - processIncludes(inputFile, input, next); | ||
| 60 | + processIncludes(filename, input, next); | ||
| 61 | 61 | }); | |
| 62 | 62 | ||
| 63 | 63 | function next(er, input) { | |
| 64 | 64 | if (er) throw er; | |
| 65 | 65 | switch (format) { | |
| 66 | 66 | case 'json': | |
| 67 | - require('./json.js')(input, inputFile, function(er, obj) { | ||
| 67 | + require('./json.js')(input, filename, (er, obj) => { | ||
| 68 | 68 | console.log(JSON.stringify(obj, null, 2)); | |
| 69 | 69 | if (er) throw er; | |
| 70 | 70 | }); | |
| 71 | 71 | break; | |
| 72 | 72 | ||
| 73 | 73 | case 'html': | |
| 74 | - require('./html.js')( | ||
| 75 | - { | ||
| 76 | - input: input, | ||
| 77 | - filename: inputFile, | ||
| 78 | - template: template, | ||
| 79 | - nodeVersion: nodeVersion, | ||
| 80 | - analytics: analytics, | ||
| 81 | - }, | ||
| 82 | - | ||
| 83 | - function(er, html) { | ||
| 84 | - if (er) throw er; | ||
| 85 | - console.log(html); | ||
| 86 | - } | ||
| 87 | - ); | ||
| 74 | + require('./html')({ input, filename, template, nodeVersion, analytics }, | ||
| 75 | + (err, html) => { | ||
| 76 | + if (err) throw err; | ||
| 77 | + console.log(html); | ||
| 78 | + }); | ||
| 88 | 79 | break; | |
| 89 | 80 | ||
| 90 | 81 | default: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -125,9 +125,7 @@ function toID(filename) { | |||
| 125 | 125 | * opts: lexed, filename, template, nodeVersion. | |
| 126 | 126 | */ | |
| 127 | 127 | function render(opts, cb) { | |
| 128 | - var lexed = opts.lexed; | ||
| 129 | - var filename = opts.filename; | ||
| 130 | - var template = opts.template; | ||
| 128 | + var { lexed, filename, template } = opts; | ||
| 131 | 129 | const nodeVersion = opts.nodeVersion || process.version; | |
| 132 | 130 | ||
| 133 | 131 | // get the section | |
| Back | FazBrowse Home | New Git URL |
0 commit comments