Skip to content

'husky install' fails if '.git' directory does not exists #851

@mondeja

Description

@mondeja

I have a postinstall script in a NPM package:

"postinstall": "is-ci || husky install",

If I download the repository using Github UI (Code -> Download ZIP), after extracting it, executing npm install raises Error: .git can't be found:

postinstall error
> [email protected] postinstall /.../simple-icons-font-develop
> is-ci || husky install

/.../simple-icons-font-develop/node_modules/husky/lib/commands/install.js:20
        throw new Error(".git can't be found");
        ^

Error: .git can't be found
    at Object.install (/.../simple-icons-font-develop/node_modules/husky/lib/commands/install.js:20:15)
    at Object.<anonymous> (/.../simple-icons-font-develop/node_modules/husky/lib/bin.js:43:19)

I can prevent the error doing something like this:

"postinstall": "node -e \"if(require('fs').existsSync('.git')){process.exit(1)}\" || is-ci || husky install",

But it seems a bit hacky. What would be the recommended way to solve this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions