从git repo子文件夹安装npm

时间:2023-02-05 15:20:53

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).

我有一个包含各种组件的repo,我希望能够将组件包含为单独的依赖项(但我不想为每个组件创建repo)。

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)

它是使用github repo的子文件夹作为npm依赖项的路径的一种方式吗?(这不会涉及为每个组件创建单独的分支)

Something like

类似的

dropdown: git+https://git@github.com/me/mycomponents.git/components/dropdown

下拉:git + https://git@github.com/me/mycomponents.git/components/dropdown

1 个解决方案

#1


2  

You kinda can.

你可以。

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:

因为版本1.7.0 git支持稀疏校验,这正是您想要的。不幸的是,npm没有任何设置来支持它,所以您必须手动操作。如果您想从BotBuilder中添加节点/核心,请将其添加到您的包中。

"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/"
}

#1


2  

You kinda can.

你可以。

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:

因为版本1.7.0 git支持稀疏校验,这正是您想要的。不幸的是,npm没有任何设置来支持它,所以您必须手动操作。如果您想从BotBuilder中添加节点/核心,请将其添加到您的包中。

"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/"
}