grunt.config()_gruntjs api
来源: http://gruntjs.cn/api/config/
获取或设置配置数据。
grunt.config([prop [, value]])
例子:
当没有传入参数时,获取全部配置数据。
//grunt.config.init({ name: 'gruntjs.cn', project: 'gruntjs.cn' });
grunt.config(); //{ name : 'gruntjs.cn', project : 'gruntjs.cn' }
当只传入一个参数时,获取一个配置的值,等同于调用 .config.get() 。
grunt.config('name'); //gruntjs.cn
当传入两个参数时,设置一个配置的值,等同于调用 .config.set() 。
grunt.config('name', 'gruntjs.cn');
源代码:
// Get/set config data. If value was passed, set. Otherwise, get.
var config = module.exports = function(prop, value) {
if (arguments.length === 2) {
// Two arguments were passed, set the property's value.
return config.set(prop, value);
} else {
// Get the property's value (or the entire data object).
return config.get(prop);
}
};
浙公网安备 33010602011771号