问题描述
我们需要将Karma测试运行程序集成到TeamCity中,为此,我想给sys-engineers小脚本(powershell或其他工具),该脚本将:
We need to integrate Karma test runner into TeamCity and for that I'd like to give sys-engineers small script (powershell or whatever) that would:
-
从某些配置文件中提取所需的版本号(我想我可以将其作为注释直接放在
karma.conf.js
中)
检查是否已在npm的全局回购中安装了已定义的业力赛跑者版本
check if the defined version of karma runner installed in npm's global repo
,如果不是,或者安装的版本比预期的旧:请安装并安装正确的版本
if it's not, or the installed version is older than desired: pick up and install right version
运行它:karma start .\Scripts-Tests\karma.conf.js --reporters teamcity --single-run
所以我真正的问题是:如果安装了所需版本的软件包,如何才能签入脚本?".您应该进行检查,还是每次都致电npm -g install
是安全的?
So my real question is: "how can one check in a script, if desired version of package installed?". Should you do the check, or it's safe to just call npm -g install
everytime?
我不想总是检查并安装最新的可用版本,因为其他配置值可能不兼容
推荐答案
要检查项目中的任何模块是否旧":
To check if any module in a project is 'old':
npm outdated
'已过期'将检查package.json
中定义的每个模块,并查看是否存在NPM注册表中有较新的版本.
'outdated' will check every module defined in package.json
and see if there is a newer version in the NPM registry.
例如,说xml2js 0.2.6
(位于当前项目的node_modules
中)已过时,因为存在较新的版本(0.2.7).您会看到:
For example, say xml2js 0.2.6
(located in node_modules
in the current project) is outdated because a newer version exists (0.2.7). You would see:
[email protected] node_modules/xml2js current=0.2.6
更新所有依赖项,如果您确信这是可取的:
To update all dependencies, if you are confident this is desirable:
npm update
或者,更新单个依赖项,例如xml2js
:
Or, to update a single dependency such as xml2js
:
npm update xml2js
这篇关于npm检查并更新软件包(如果需要)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!