gpt4 book ai didi

angularjs - 有没有办法通过 grunt 任务自动生成 karma.conf.js?

转载 作者:行者123 更新时间:2023-12-03 20:48:11 25 4
gpt4 key购买 nike

我一直在使用 Yeoman.io 基础 angularjs 生成器附带的 gruntfile 的修改版本,并且 grunt-bower-install 命令对于使我的基础 index.html 文件保持最新状态非常方便具有 bower 依赖性。

但是,当我执行 bower install (package) --save 然后 grunt bower-install 时,我的 index.html 会更新,但我的 karma.conf.js 不会更新,这意味着我需要手动添加新文件当 karma 运行测试套件时要加载的文件列表(否则注入(inject)器无法尝试注入(inject)不存在的包)。

有什么简单易行的方法可以将它添加到我的 grunt 工作流程中吗?这不是世界末日,但它是那些容易忘记的事情之一。

最佳答案

我实际上想出了一个解决这个问题的方法。查看https://github.com/stephenplusplus/grunt-bower-install/issues/35#issuecomment-32084805

'bower-install': {
app: {
src: '<%= yeoman.app %>/index.html',
ignorePath: '<%= yeoman.app %>/'
},
test: {
src: 'karma.conf.js',
fileTypes: {
js: {
block: /(([\s\t]*)\/\/\s*bower:*(\S*))(\n|\r|.)*?(\/\/\s*endbower)/gi,
detect: {
js: /'.*\.js'/gi
},
replace: {
js: '\'{{filePath}}\','
}
}
}
}
}

关于angularjs - 有没有办法通过 grunt 任务自动生成 karma.conf.js?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21842259/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com