hdoc-tools 0.15.3 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hdoc-validate.js +30 -0
- package/package.json +1 -1
package/hdoc-validate.js
CHANGED
@@ -194,6 +194,32 @@
|
|
194
194
|
return nav_errors;
|
195
195
|
};
|
196
196
|
|
197
|
+
const checkRedirects = async function (source_path) {
|
198
|
+
let errors = [];
|
199
|
+
for (const key in redirects) {
|
200
|
+
if (redirects.hasOwnProperty(key)) {
|
201
|
+
let redir_locations = [
|
202
|
+
path.join(source_path, redirects[key].location + '.md'),
|
203
|
+
path.join(source_path, redirects[key].location, 'index.md'),
|
204
|
+
path.join(source_path, redirects[key].location + '.html'),
|
205
|
+
path.join(source_path, redirects[key].location + '.htm'),
|
206
|
+
path.join(source_path, redirects[key].location, 'index.html'),
|
207
|
+
path.join(source_path, redirects[key].location, 'index.htm')
|
208
|
+
];
|
209
|
+
let redir_location_ok = false;
|
210
|
+
for (let i = 0; i < redir_locations.length; i++) {
|
211
|
+
if (fs.existsSync(redir_locations[i])) {
|
212
|
+
redir_location_ok = true;
|
213
|
+
break;
|
214
|
+
}
|
215
|
+
}
|
216
|
+
if (!redir_location_ok)
|
217
|
+
errors.push(`Redirect location does not exist: ${redirects[key].location}`);
|
218
|
+
}
|
219
|
+
}
|
220
|
+
return errors;
|
221
|
+
};
|
222
|
+
|
197
223
|
const checkRedirect = function (source_path, nav_path) {
|
198
224
|
let response = {
|
199
225
|
exists: false,
|
@@ -484,6 +510,10 @@
|
|
484
510
|
const nav_errors = await checkNavigation(source_path, nav_items, exclude_spellcheck);
|
485
511
|
if (nav_errors.length > 0) meta_errors.push(...nav_errors);
|
486
512
|
|
513
|
+
// Check redirects
|
514
|
+
const redirect_errors = await checkRedirects(source_path);
|
515
|
+
if (redirect_errors.length > 0) meta_errors.push(...redirect_errors);
|
516
|
+
|
487
517
|
if (meta_errors.length > 0) {
|
488
518
|
console.log('\r\n-----------------------');
|
489
519
|
console.log(' Validation Output ');
|