Search code examples
shellgruntjsgrunt-shell

Add a devDependency that executes a shell command


To run an external command as a grunt task, we can use grunt-shell, grunt-exec or grunt-spawn.

To build a project, I must ensure that a certain tool is installed. The tool isn't available via npm, but requires running a command to install. So I need to add a devDependency to a package.json that involves executing an external command. How can I do that?


Solution

  • You can define preinstall/postinstall commands in the scripts block of the package.json:

    {
      "scripts": {
        "preinstall": "your install-command",
        "postinstall": "your install-command"
      }
    }
    

    Choose which one fits your needs!