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

chainsmoker

v1.0.3

Published

Elegant, generically typed, boolean micromatch for lists of file paths

Downloads

37

Readme

chainsmoker

version license types build code style

Elegant, generically typed, boolean micromatch for lists of file paths in TypeScript.

  • Works with CommonJS and ES Modules, too.
  • Safer and more concise than using .filter() and .length.
  • Designed for concise syntax in dangerfiles but not tied to them in any way.

I'm pleased to say as of Danger.js 7.1, this helper is vendored into Danger and accessible as danger.fileMatch.

Usage

const { danger, fail, message, warn } = require('danger')
const chainsmoker = require('chainsmoker')

// In this example, these are all arrays of relative paths.
const fileMatch = chainsmoker({
  created: danger.git.created_files,
  modified: danger.git.modified_files,
  updated: danger.git.modified_files.concat(danger.git.created_files),
  deleted: danger.git.deleted_files,
})

const documentation = fileMatch(
  '**/*.md',
  'lib/all-badge-examples.js',
  'frontend/components/usage.js'
)
const packageJson = fileMatch('package.json')
const packageLock = fileMatch('package-lock.json')
const helpers = fileMatch('lib/**/*.js', '!**.spec.js')
const helperTests = fileMatch('lib/**/*.spec.js')

// This is `true` whenever there are matches in the corresponding path array.
if (documentation.updated) {
  message('We :heart: our [documentarians](http://www.writethedocs.org/)!')
}

if (packageJson.modified && !packageLock.modified) {
  warn('This PR modified package.json, but not package-lock.json')
}

if (helpers.created && !helperTests.created) {
  warn('This PR added helper modules in lib/ but not accompanying tests.')
} else if (helpers.updated && !helperTests.updated) {
  warn('This PR modified helper modules in lib/ but not accompanying tests.')
}

fileMatch.getKeyedPatterns()

Return an object containing arrays of matched files instead of the usual boolean values.

Installation

Requires Node 8+.

npm install --save-dev chainsmoker

Contribute

  • Issue Tracker: https://github.com/paulmelnikow/chainsmoker/issues
  • Source Code: https://github.com/paulmelnikow/chainsmoker

Pull requests welcome!

Support

If you are having issues, please let me know.

The name :smoking:

The name was inspired by the idea of a chainable file-set object using minimatch. It's also for Danger… maybe that was part of the inspiration.

I ended up with something simpler that doesn't rely on chaining, though I kept the name.

Acknowledgements

Thanks to @orta for reviewing this and shipping it with Danger.

License

The project is licensed under the MIT license.