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

@karnov/ifchanged

v1.0.9

Published

Only run provided command if a source has changed

Downloads

19

Readme

ifchanged

Conditionally run a command if watched files have changed, for instance:

ifchanged yarn build

Running the above multiple times will only result in executing 'yarn build' if a source file has changed since last run, otherwise it is a noop.

To specify which files to watch:

ifchanged --watch="src/**/*.js"

If multiple steps depend on whether the files have changed:

 ifchanged --step=build yarn build
 ifchanged --step=build:docs yarn build:docs

To provide flags to the command, use '--' to separate them from flags to ifchanged:

ifchanged --step=build -- yarn run build --step=docs

Options:

--help         Show help                                             [boolean]

--version      Show version number                                   [boolean]

--watch, -w    Pattern to watch for changes using glob syntax.
     [default: ["src/**/*.js","tests/**/*.js","node_modules/**/package.json"]]

--rootDir, -r  Root directory to watch.
                                     [default: "/home/mike/Private/ifchanged"]

--cache, -c    Path to save internal ifchanged data to.
                    [default: "/home/mike/Private/ifchanged/.ifchanged_cache"]

--step, -s     Step name. Makes it possible to run several steps when the
               watched files have changed.                            [string]

--config       Path to JSON config file
                     [default: "/home/mike/Private/ifchanged/.ifchanged.json"]

CAVEATS

Watching different file sets

Providing different '--watch' settings between runs won't work as expected unless a different '--cache' is provided as well:

ifchanged --watch=src/*.js yarn build
ifchanged --watch=docs/*.mdx yarn build:docs

The above will not work since the same cache is being used to watch two different sets of files. To get the expected result, provide a different cache to at least one of the calls:

ifchanged --watch=src/*.js yarn build
ifchanged --watch=docs/*.mdx --cache=.ifchanged-docs yarn build:docs

Sub-second changes

To optimize for performance, ifchanged only uses file modification times and sizes to check if a new run is required. Since mtime only has a resolution of seconds, ifchange can't detect changes where it is being run with a second or less between each run.

Developing

Download and run tests

git clone [email protected]:karnov/ifchanged
cd ifchanged
yarn
yarn test

Publishing

yarn publish

Remember to log in first. If publishing fails, make sure that you have access to the karnov organization at npmjs.com.

Reporting bugs

https://github.com/karnov/ifchanged/issues

Author

Michael Zedeler [email protected].

Copyright and license

Copyright Karnov Group A/S 2018, licensed under MIT license.