Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Commit

Permalink
Updated dependencies and fixed output filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaurav Nelson committed Jan 31, 2018
1 parent 011af37 commit 4c8033b
Show file tree
Hide file tree
Showing 3 changed files with 293 additions and 165 deletions.
13 changes: 9 additions & 4 deletions asciidoc-link-check
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ var statusLabels = {

var error = false;
var opts = {};
var filenameOutput = "";
var stream = process.stdin; // read from stdin unless a filename is given
program.option('-p, --progress', 'show progress bar').arguments('[filenameOrUrl]').action(function (filenameOrUrl) {
filenameOutput = filenameOrUrl;
if (/https?:/.test(filenameOrUrl)) {
stream = request.get(filenameOrUrl);
try { // extract baseUrl from supplied URL
Expand All @@ -34,17 +36,20 @@ program.option('-p, --progress', 'show progress bar').arguments('[filenameOrUrl]
opts.baseUrl = 'file://' + path.dirname(path.resolve(filenameOrUrl));
stream = fs.createReadStream(filenameOrUrl);
}
}).parse(process.argv);
})
//.option('-f, --showfilenames', 'show filenames')
.parse(process.argv);

opts.showProgressBar = (program.progress === true); // force true or undefined to be true or false.
//opts.showFileNames = (program.showfilenames === true);

var asciidoc = ''; // collect the asciidoc data, then process it
stream.on('data', function (chunk) {
asciidoc += chunk.toString();
}).on('end', function () {
if (process.argv[2]) {
console.log(chalk.blue('\nFILE: ' + process.argv[2]))
}
//if (program.showfilenames) {
console.log(chalk.cyan('\nFILE: ' + filenameOutput))
//}
asciidocLinkCheck(asciidoc, opts, function (err, results) {
if (results.length === 0) {
console.log(chalk.yellow('No hyperlinks found!\n'))
Expand Down
Loading

0 comments on commit 4c8033b

Please sign in to comment.