npmignore .sh 文件在除一个目录之外的所有目录中
npmignore .sh files in all but one directory
我想忽略项目中的所有 .sh 文件,但位于特定目录中的文件除外,我们将该目录称为 foo。
所以我们有:
project/
bar.sh
baz.sh
foo/
a.sh
b.sh
我不想将 bar.sh
和 baz.sh
发布到 NPM,但我 想发布 a.sh
和 b.sh
到 NPM。原来我在foo目录外有好几个.sh文件,一口气忽略掉比较方便
我可以在我的 .npmignore
文件中添加什么来完成此操作?
在 .npmignore 的文档中指出:
.npmignore
files follow the same pattern rules as .gitignore
files:
在这种情况下,您将忽略所有 .sh
文件(即 *.sh
),然后使用撇号 !
否定该模式并指定要包含的文件夹名称。例如:
示例 1
# ignore all .sh files
*.sh
# include .sh files in the folder foo
!foo/*.sh
使用此配置,(在下面显示的示例文件夹结构的上下文中),所有这些文件都将被忽略:a.sh
、b.sh
、 e.sh
、f.sh
以下文件是 included/published:c.sh
和 d.sh
。
注意:e.sh
和 f.sh
在使用此配置时也会被忽略,因为它们位于子文件夹中。
示例 2
要同时 include/publish 文件夹 foo
的任何子文件夹中的 .sh
文件,请按如下方式配置您的 .npmignore
:
# ignore all .sh files
*.sh
# include .sh files in the folder foo and any inside its sub folders
!foo/**/*.sh
使用此配置,(在下面显示的示例文件夹结构的上下文中),仅忽略文件:a.sh
和 b.sh
。所有其他 .sh
个文件已发布。
示例文件夹结构
project
├── a.sh
├── b.sh
└── foo
├── baz
│ ├── e.sh
│ └── f.sh
├── c.sh
└── d.sh
我想忽略项目中的所有 .sh 文件,但位于特定目录中的文件除外,我们将该目录称为 foo。
所以我们有:
project/
bar.sh
baz.sh
foo/
a.sh
b.sh
我不想将 bar.sh
和 baz.sh
发布到 NPM,但我 想发布 a.sh
和 b.sh
到 NPM。原来我在foo目录外有好几个.sh文件,一口气忽略掉比较方便
我可以在我的 .npmignore
文件中添加什么来完成此操作?
在 .npmignore 的文档中指出:
.npmignore
files follow the same pattern rules as.gitignore
files:
在这种情况下,您将忽略所有 .sh
文件(即 *.sh
),然后使用撇号 !
否定该模式并指定要包含的文件夹名称。例如:
示例 1
# ignore all .sh files
*.sh
# include .sh files in the folder foo
!foo/*.sh
使用此配置,(在下面显示的示例文件夹结构的上下文中),所有这些文件都将被忽略:a.sh
、b.sh
、 e.sh
、f.sh
以下文件是 included/published:c.sh
和 d.sh
。
注意:e.sh
和 f.sh
在使用此配置时也会被忽略,因为它们位于子文件夹中。
示例 2
要同时 include/publish 文件夹 foo
的任何子文件夹中的 .sh
文件,请按如下方式配置您的 .npmignore
:
# ignore all .sh files
*.sh
# include .sh files in the folder foo and any inside its sub folders
!foo/**/*.sh
使用此配置,(在下面显示的示例文件夹结构的上下文中),仅忽略文件:a.sh
和 b.sh
。所有其他 .sh
个文件已发布。
示例文件夹结构
project
├── a.sh
├── b.sh
└── foo
├── baz
│ ├── e.sh
│ └── f.sh
├── c.sh
└── d.sh