Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring in lodash.mergeWith, use to merge the babel plugins #843

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ docs/
**/jasmine.js
**/lib/colors.js
**/underscore.js
**/lodash.mergewith.js
**/backbone.js
Alloy/grammar
Alloy/builtins/social.js
Alloy/builtins/moment
Alloy/builtins/moment.js
Alloy/template
Alloy/template
11 changes: 9 additions & 2 deletions Alloy/commands/compile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var ejs = require('ejs'),

// alloy requires
_ = require('../../lib/alloy/underscore'),
mergeWith = require('./lodash.mergewith'),
logger = require('../../logger'),
U = require('../../utils'),
tiapp = require('../../tiapp'),
Expand Down Expand Up @@ -1123,17 +1124,23 @@ function optimizeCompiledCode(alloyConfig, paths) {
});
}

function arrayConcatMerger(objValue, srcValue) {
if (_.isArray(objValue)) {
return objValue.concat(srcValue);
}
}

function transformFiles(alldone) {
async.whilst(
function() { return (files = _.difference(getJsFiles(), lastFiles)).length > 0; },
function(next) {
async.each(files, function(file, callback) {
var options = _.extend(_.clone(sourceMapper.OPTIONS_OUTPUT), {
var options = mergeWith(_.clone(sourceMapper.OPTIONS_OUTPUT), {
plugins: [
[require('./ast/builtins-plugin'), compileConfig],
[require('./ast/optimizer-plugin'), compileConfig.alloyConfig],
]
}),
}, arrayConcatMerger),
fullpath = path.join(compileConfig.dir.resources, file);

logger.info('- ' + file);
Expand Down