在文檔爲.npmignore它指出:
.npmignore
文件遵循same pattern rules爲.gitignore
文件:
在這種情況下你忽略所有的.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
包括/發佈了以下文件:c.sh
和d.sh
。
注意:e.sh
和f.sh
也會被忽略,因爲它們位於子文件夾中。
例2
也包括/發佈.sh
文件夾foo
的任何子文件夾,然後配置你的.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