Reputation: 8920
I have a repo with various components and I want to be able to include the components as individual dependencies (but I don't want to create a repo per component).
Is it a way to use a subfolder of a github repo as the path for a dependency in npm ? (that will not involve creating separate branches per component)
Something like
dropdown: git+https://[email protected]/me/mycomponents.git/components/dropdown
Upvotes: 18
Views: 6062
Reputation: 13916
Since version 1.7.0 git supports sparse checkouts, which is exactly what you want. Unfortunately npm doesn't have anything in set to support it, so you have to do it manually. Given you want to add Node/core
from BotBuilder, add this to your package.json
:
"scripts": {
"postinstall": "mkdir BotBuilder; cd BotBuilder; git init; git remote add -f origin https://github.com/Microsoft/BotBuilder.git; git config core.sparseCheckout true; echo \"Node/core\" >> .git/info/sparse-checkout; git pull --depth=1 origin master; cd ..; npm i ./BotBuilder/Node/core/"
}
Upvotes: 4