Is there a way I can hook an npm install
when I branch in Source Control explorer? Or if I can access a powershell window to run a script to do that for me?

- 1,297
- 10
- 12
-
What's the detail mean of hook an npm install ? Did you mean this https://docs.npmjs.com/misc/scripts#hook-scripts `If you want to run a specific script at a specific lifecycle event for ALL packages, then you can use a hook script.` – PatrickLu-MSFT Sep 14 '16 at 03:44
-
sorry for being unclear, didn't mean hook as in NPM's `/.hooks`. Wanted to execute a script when I branch in Source Control Explorer – julianljk Sep 14 '16 at 14:26
-
So you want to run "npm install" command after create a branch? – Eddie Chen - MSFT Sep 15 '16 at 00:50
-
@Eddie-MSFT yes, I want to automate npm install when I branch in TFS. Essentially – julianljk Sep 15 '16 at 14:16
-
Not exactly what you are asking for, but you could try and use the node js TaskRunner-Extension in VS and register `npm install` to run when you load the project. – nozzleman Nov 10 '16 at 06:44
2 Answers
No, there is no way to run npm install when you create branch. If you have a large amount of projects need to run npm install after branch, you can create a powershell or batch script to do this just as you mentioned in your question.

- 29,708
- 2
- 46
- 60
You can try do this through a custom Check-in policy. After branching in Source Control explorer, you need to check in the pending changes. These check-in policies require the user to take actions when they conduct a check-in to source control, for example a user can be required to associate a work item with a changeset.
About how to create a custom check-in policy you can refer the detailed answer from jessehouwing in this TFS Client side hook . You can also take a look at this blog Creating TFS Custom Check-in Policy

- 1
- 1

- 49,478
- 5
- 35
- 62
-
-
Looked at it, I don't need to do npm install before checking in, I need it when I'm checking OUT, because I need to have all my dependencies in before I start developing – julianljk Sep 15 '16 at 14:28