排除 npm 包中的测试代码? [英] Exclude test code in npm package?

查看:68
本文介绍了排除 npm 包中的测试代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

npm 的 package.json 文档的 devDependencies 部分说要在那里列出您的测试依赖项,以便用户的包不必拉下额外的依赖项.在这种情况下,将我的测试目录也添加到 .npmignore 是否有意义?

The devDependencies section of npm's package.json documentation says to list your test dependencies there so that users of your package don't have to pull down extra dependencies. Would it make sense to also add my test directory to .npmignore in that case?

推荐答案

是的,这就是大多数人所做的,这里有一些流行的 Node.js 模块的 npmignore 文件:

Yes that's what most people do, here are some npmignore files for popular Node.js modules:

https://github.com/socketio/socket.io/blob/ab46351a8446516fb4eea3b8333f7c0f18afaac5/.npmignore

其他人将他们想要在他们的 package.json files 设置中发布的内容列入白名单:

Other people whitelist what they want published in their package.json files setting:

https://github.com/senchalabs/connect/blob/master/包.json
https://github.com/strongloop/express/blob/master/package.json

这篇关于排除 npm 包中的测试代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆