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

ignore-dependency-scripts

v1.0.1

Published

Script to prevent dependencies to execute post/pre install scripts when installed directly from git.

Downloads

1,161

Readme

Ignore dependency post/pre install scripts

License MIT npm version npm downloads

Script to prevent dependencies to execute post/pre install scripts when installed directly from git.

Alternative to typicode/pinst and bahmutov/am-i-a-dependency.

Why?

Sometimes when working with private projects, we have the need to reuse some parts of our code in many projects. But, we know that maintaining a private npm registry is a pain and requires a lot of attention.

So, the easiest way, is to install our private repo as a dependency directly from git. But, this comes with some caveats like the inability to use .npmignore and the lack of an option to "prevent pre/post scripts" when installed as a dependency.

Some examples of scripts that we might want to prevent from running when installed as a dependency is:

  • husky install
  • npx pod-install

It's a solution for:

  • https://stackoverflow.com/q/72092997/2826279
  • https://stackoverflow.com/q/54212147/2826279
  • https://stackoverflow.com/q/23505318/2826279
  • https://stackoverflow.com/q/44749524/2826279
  • https://stackoverflow.com/q/41015620/2826279

Usage

Replace this:

  // package.json

  "name": "my-library",
  "scripts:" { 
    // "start", "test", "build", etc
    "postinstall/preinstall/prepare/etc": "your && scripts && here"
  },

With this:

  // package.json

  "name": "my-library",
  "scripts:" { 
    // "start", "test", "build", etc
    "postinstall/preinstall/prepare/etc": "npx --yes ignore-dependency-scripts \"your && scripts && here\""
  },

Replace your && scripts && here by any post/pre install script that you want, like husky install, npx pod-install or both.

Now, when you run yarn install or npm install in ./my-library the your && scripts && here will run normally.

But, when you install my-library as a dependency (aka yarn add url/to/my-library.git) in another repository, the your && scripts && here will be ignored.

How it works

Consider the usage example above.

When npx --yes ignore-dependency-scripts is executed, it will check if there is a .git folder inside the root directory. (thanks to https://stackoverflow.com/a/68915638/2826279)

If the .git folder exists, then you are installing the dependencies of ./my-library directly.

If the .git folder DOES NOT exist, then you are installing my-library as a dependency in another repository.

I think that in future we can extend this package to use other strategies too. PRs will be welcome.

Contribute

New features, bug fixes and improvements are welcome! For questions and suggestions, use the issues.

Donate

License

The MIT License (MIT)

Copyright (c) 2022 Douglas Nassif Roma Junior

See the full license file.