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

Updated dependencies and fixed output filenames #8

Merged
merged 1 commit into from
Jan 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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