在我的Gruntfile.js中,我发现自己concatenating了很多glob个结果。现在它似乎并没有影响构建时间,但我想知道是否有一种更高效的连接多个数组的方式。
var pattern = 'lib/module/{products,payments,users}';
var code = {
project: []
.concat(glob.sync('lib/editor/*.js'))
.concat(glob.sync('lib/jasmine/helper/*.js'))
.concat(glob.sync('lib/task/*.js'))
.concat([
'Gruntfile.js',
'models.js',
'routes.js',
'server.js'
]),
backend: []
.concat(glob.sync(pattern + '/{model}/*.js'))
.concat(glob.sync(pattern + '/route/*.js')),
frontend: []
.concat([
'lib/application.js'
])
.concat(glob.sync(pattern + '/collection/*.js'))
.concat(glob.sync(pattern + '/editor/*.js'))
.concat(glob.sync(pattern + '/router/*.js'))
.concat(glob.sync(pattern + '/view/*.js')),
spec: []
.concat(glob.sync(pattern + '/spec/*.js'))
};