Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submodules :: Hook Should Work Both Inside & Outside Docker Containers #230

Open
lots0logs opened this issue Dec 25, 2018 · 0 comments
Open

Comments

@lots0logs
Copy link

When the hook is installed in a git submodule the return value of getNodeModulesAbsoluteEntryPoint() is a static path from the time the hook file was generated. This causes problems if you are using containers as part of your dev workflow. Basically the hook fails if you run git from outside the container when the hook was installed from inside the container (and vise-versa).

Doing something like the following should solve the problem:

let _nodeModulesPath = path.resolve(__dirname, '../', '../', 'node_modules')

  if (! fs.existsSync(_nodeModulesPath)) {
    // We might be in a git submodule
    const prefix = __dirname.split(/[/\\]\.git[/\\]/).shift()
    const suffix = __dirname.split(/[/\\]hooks[/\\]/).pop()

    _nodeModulesPath = path.resolve(path.relative(__dirname, `${prefix}${path.sep}${suffix}`), 'node_modules')
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant