img-link-checker

1.1.0 • Public • Published

img-link-checker

Actions Status npm version NPM License

Check any file for broken links and images. The script in this package parses any file that you specify and checks all absolute links in it. It makes request to URL specified in each link and if response status code is not 200 (OK) then the process exits and the list of broken links is outputted.

Installation

This is a lightweight package with only 1 dependency (axios). To install it just run:

npm install img-link-checker --save-dev

Usage

From the code

For example if you want to check README.md for broken links and images just require img-link-checker and call checkFile('./path/to/file/', 'README.md');:

const { checkFile } = require('img-link-checker');

checkFile('./README.md');

From the command line

Checking for broken links and images can also be invoked directly from the command line - just install the package and launch the command with TARGET_FILE_PATH environment variable:

TARGET_FILE_PATH='./README.md' node node_modules/.bin/img-link-checker

Note: if you need to ignore some of the links - you can specify an optional second argument with an array of links that should not be checked:

const { checkFile } = require('img-link-checker');

checkFile('./README.md', ['https://www.linkedin.com/in/test/']);

Thanks

If this link and image checking tool was helpful to you, please give it a ★ Star on GitHub.

Package Sidebar

Install

npm i img-link-checker

Weekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

13.1 kB

Total Files

7

Last publish

Collaborators

  • marketionist