npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-link-checker

v0.2.0

Published

Finds broken links and resources on websites

Downloads

653

Readme

grunt-link-checker

Run node-simple-crawler to discover broken links on your website.

NPM version Build Status Dependency Status devDependency Status

Getting Started

If you haven't used grunt before, be sure to check out the Getting Started guide, as it explains how to create a gruntfile as well as install and use grunt plugins. Once you're familiar with that process, install this plugin with this command:

npm install grunt-link-checker --save-dev

Then add this line to your project's Gruntfile.js gruntfile:

grunt.loadNpmTasks('grunt-link-checker');

Documentation

grunt-link-checker will by default find any broken internal links on the given site and will also find broken fragment identifiers by using cheerio to ensure that an element exists with the given identifier. You can figure more options that are available via node-simplecrawler.

Minimal Usage

The minimal usage of grunt-link-checker runs with a site specified and an optional options.initialPort:

linkChecker: {
  dev: {
    site: 'localhost',
    options: {
      initialPort: 9001
    }
  }
}

Recommended Usage

In addition to the above config which tests a local version of your site before deployment, you can add an additional target to run post-deployment. This will verify that your assets were deployed correctly and are being resolved correctly after any revisioning or path modifications during deployment:

linkChecker: {
  // Use a large amount of concurrency to speed up check
  options: {
    maxConcurrency: 20
  },
  dev: {
    site: 'localhost',
    options: {
      initialPort: 9001
    }
  },
  postDeploy: {
    site: 'mysite.com'
  }
}

Custom options

noFragment

  • Type: Boolean
  • Default: false

Set this to true to speed up your test by not verfiying fragment identifiers.

callback

Type: Function

Function that receives the instantiated crawler object so that you can add events or other listeners/config to the crawler.

Here is an example config using the callback option to ignore localhost links which have different ports:

linkChecker: {
  dev: {
    site: 'localhost',
    options: {
      initialPort: 9001,
      callback: function (crawler) {
        crawler.addFetchCondition(function (url) {
          return url.port === '9001';
        });
      }
    }
  }
}

simple-crawler options

Every option specified in the node-simplecrawler is available:

https://github.com/cgiffard/node-simplecrawler#configuring-the-crawler

Changelog

  • 0.2.0 - Updated dependencies.
  • 0.1.0 - Updated dependencies, changed task name to linkChecker.
  • 0.0.6 - Added logging for initially fetched URL and logged status codes for failed fetches.
  • 0.0.5 - Added error reporting if initial site URL fails.
  • 0.0.4 - Added callback option.
  • 0.0.3 - Fixed repo link in package.json and fixed error reporting for a failed initial URL.
  • 0.0.2 - Added noFragment flag.
  • 0.0.1 - Check to make sure # URLs resolve to content with a corresponding ID.
  • 0.0.0 - Initial release.