如何将package.json数组传递给grunt.js [英] How to pass in package.json array to grunt.js
本文介绍了如何将package.json数组传递给grunt.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法将一个数组传递给package.json文件中的grunt.js?我尝试了几种不同的方式,但他们都没有效果。我目前有:
is there a way to pass in an array to grunt.js from the package.json file? I've tried a few different ways and none of them seem to work. I currently have:
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: '<json:package.json>',
lint: {
files: '<%= pkg.lint.join(", ") %>'
}
// Default task 'lint qunit concat min'
grunt.registerTask('default', 'lint');
};
package.json
package.json
{
"lint": [
"grunt.js",
"test.js"
]
}
我唯一能找到的解决方案是传递一个特定的索引这个数组;例如<%= pkg.lint [0]%>。
在此先感谢您的帮助!
The only solution that I have been able to find is to pass in a specific index of the array; e.g. <%= pkg.lint[0] %>. Thanks in advance for your help!
推荐答案
因为gruntjs在节点中运行,所以你可以像访问package.json一样:
Since gruntjs in run in node you can access the package.json like:
var package = require('./package.json'),
property = package.property[0];
这篇关于如何将package.json数组传递给grunt.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文