Search code examples
javascriptbashnpmsh

Can I include bash/sh files as dependencies in package.json?


I have a bash script which I wrote for publishing modules to npm: publish.sh As I still work on tweaking this script a lot, every time I change it, I need to make the changes in every copy of it in every npm module I am managing.

Is there a way to include this as a dependency in my package.json file so that I just need to run npm update; npm install in order to update it? Maybe the sh file would need to be executed by some wrapper javascript or something like that..?


Solution

  • Answering my own question a few years later: What I was looking for was to be able to add the following to my package.json file:

      "name": "your-package-name",
      "version": "1.0.0",
      "bin": "./path/to/your-script.sh"
    

    or

      "bin": {
        "command-name-1": "./path/to/your-first-script.sh",
        "command-name-2": "./path/to/your-second-script.sh"
      }
    

    So that they would be installed to the .bin file under node_modules.

    I haven't tried this by referencing a URI to a version controlled .sh file, but that would be the ideal flow I was looking for.