Skip to content
Permalink
Browse files
fixing merge with no target
  • Loading branch information
Anis Kadri committed Apr 11, 2014
1 parent 752be1b commit b225cd30878af37d0087ae17278dd410e0affe7f
Showing 1 changed file with 10 additions and 8 deletions.
@@ -1,34 +1,36 @@
// FIXME this is extremely guettho
module.exports = function(target, method) {

var old = target;
target = target.replace(/^window(\.)?/, '');

var lastDot = target.lastIndexOf('.');
var namespace = target.substr(0, lastDot);
var lastName = target.substr(lastDot + 1);
var props = target.split(".");
var code = "";
for(var i = 1, len = props.length ; i <= len ; i++) {
var sub = props.slice(0, i).join(".");
code += util.format("window.%s = window.%s || {};\n", sub, sub);

if(target !== "") {
for(var i = 1, len = props.length ; i <= len ; i++) {
var sub = props.slice(0, i).join(".");
code += util.format("window.%s = window.%s || {};\n", sub, sub);
}
}

props.unshift('window');
var object = props.slice(0, props.length - 1).join('.');
// code = "\n";
if(method === "c") {
return util.format(
"%s\n;require('cordova/builder').assignOrWrapInDeprecateGetter(%s, '%s', module.exports);",
"%s\nrequire('cordova/builder').assignOrWrapInDeprecateGetter(%s, '%s', module.exports);",
code,
object,
lastName
);
} else if(method === "m") {
return util.format(
"%s\n;require('cordova/builder').recursiveMerge(%s, '%s', module.exports);",
"%s\n;require('cordova/builder').recursiveMerge(%s, module.exports);",
code,
object,
lastName
object
);
}
}

0 comments on commit b225cd3

Please sign in to comment.