captainhook icon indicating copy to clipboard operation
captainhook copied to clipboard

Allow a working directory to be specified

Open shadowhand opened this issue 3 years ago • 2 comments

We are adding some additional (micro) services to our project, so now we have:

composer.json
composer.lock
services/
  foo/
    package.json
    package-lock.json

I'd like to be able to check for changes to services/foo/package{-lock,}.json and execute npm install but within the services/foo directory.

Is there any way that I can tell CaptainHook to execute the action in a different directory? I'm looking for something like:

{
  "action": "npm install",
  "options": {
    "in-directory": "services/foo"
  },
  "conditions": [ ]
}

shadowhand avatar Dec 22 '22 16:12 shadowhand

You could do something like

"action": "cd services/foo && npm install && cd ../.."

That should work

sebastianfeldmann avatar Dec 22 '22 17:12 sebastianfeldmann

That seems to work. I think it would still be really useful to have some kind of "working directory" option that would cause both the conditions and the action to operate somewhere other than the root directory.

shadowhand avatar Dec 22 '22 21:12 shadowhand