Skip to content
Permalink
Browse files
fixing merge with no target
  • Loading branch information
Anis Kadri committed Apr 9, 2014
1 parent 7d85eaa commit 1e758680a101f7d7744f2889cf588cf7d0de7621
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 1e75868

Please sign in to comment.