Search code examples
npmnpm-scriptshuskygit-husky

How are devinstall and devuninstall scripts being used?


I am trying to reuse husky for other projects (not just config file), building a lib of sorts that will be used by all other projects. I cannot understand how and when devinstall and devuninstall scripts are executed. Cannot find any documentation either on npmjs.com. Can someone help understand when this are getting executed please?


Solution

  • I've been trying to understand that too. Turns out they do something at publication time that renames the _install script into install.

    Here's the script field of the package.json found in the husky folder when installed through npm.

    "scripts": {
        "build": "del-cli lib && tsc",
        "devinstall": "npm run build && npm run _install -- node_modules/husky && node scripts/dev-fix-path",
        "devuninstall": "npm run build && npm run preuninstall -- node_modules/husky",
        "fix": "npm run lint -- --fix",
        "install": "node husky install",
        "lint": "tslint 'src/**/*.ts'",
        "postpublish": "pinst --disable",
        "postversion": "git push && git push --tags",
        "prepublishOnly": "npm run test && npm run build && pinst --enable && pkg-ok",
        "preuninstall": "node husky uninstall",
        "test": "npm run lint && jest",
        "version": "jest -u && git add -A src/installer/__tests__/__snapshots__"
      }
    

    Although I can't figure where that is done