The arg
can be a link, file path, or directory path. The callback
will be given the broken link and path of the link.
import linkInspector from 'link-inspector';
linkInspector('http://example.com', function (link) {
console.log(`Broken link found: ${link}`);
});
If you want to use linkInspector on all the files in a directory:
import linkInspector from 'link-inspector';
linkInspector('./path/to/directory', function (link, path, lineNumber) {
console.log(`Broken link ${link} found in ${path} on line ${lineNumber}`);
});
There is also a cli. You can install it with:
npm install link-inspector -g
You can use it on a links, file paths, or directory paths.
npx link-inspector ./path/to/directory
The cli tool will write the link in an output
folder.
output/
│
├── subfolder/
│ ├── file1.txt
│ └── file2.txt
│
├── file3.txt
└── file4.txt
-
Clone
git clone https://github.com/justindhillon/link-inspector.git cd link-inspector
-
Install Dependencies
npm install
-
Build the npm package
npm run build
-
Run the npm package
npx link-inspector <file/directory path>
-
Testing the npm package
npm run test
link-inspector
uses the AGPL-3.0 license.