Repository: cordova-js Updated Branches: refs/heads/master 00ee00f39 -> 8434678b1
removed contacts hack, added regex to handle geolocation Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/cc3c12fc Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/cc3c12fc Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/cc3c12fc Branch: refs/heads/master Commit: cc3c12fc331bb3d5d0c41e26915e6c4550fcb7da Parents: 9cfeab7 Author: Steven Gill <[email protected]> Authored: Tue Jun 3 14:46:26 2014 -0700 Committer: Steven Gill <[email protected]> Committed: Tue Jun 3 14:46:26 2014 -0700 ---------------------------------------------------------------------- tasks/lib/require-tr.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-js/blob/cc3c12fc/tasks/lib/require-tr.js ---------------------------------------------------------------------- diff --git a/tasks/lib/require-tr.js b/tasks/lib/require-tr.js index 6b8c2e1..15e6265 100644 --- a/tasks/lib/require-tr.js +++ b/tasks/lib/require-tr.js @@ -48,9 +48,7 @@ var requireTr = { data = data.replace(/modulemapper\.clobbers.*\n/, util.format('navigator.app = require("%s/src/android/plugin/android/app")', root)); } - if(file.match(/ios\/Contact.js$/)) { - data = data.replace(/'\.\/ContactError'/, "'../ContactError'"); - } + this.queue(_updateRequires(data)); this.queue(null); } @@ -85,7 +83,7 @@ function _updateRequires(code) { // check if function call is a require('module') call if(node.expression.name === "require" && node.args.length === 1) { var module = node.args[0].value; - // make sure require only has one argument and that it starts with cordova (old style require.js) + // make sure require only has one argument and that it starts with cordova (old style require.js) if(module !== undefined && module.indexOf("cordova") === 0) { @@ -116,15 +114,21 @@ function _updateRequires(code) { } } else if(module !== undefined && ( module.indexOf("org.apache.cordova") !== -1 || - module.indexOf("./") === 0 ) ) { + module.indexOf("./") === 0 || module.indexOf("../") === 0 ) ) { var modules = requireTr.getModules(); - if(module.indexOf("./") === 0) { - module = module.replace('/', ''); + + if(module.indexOf("../") === 0){ + module = module.replace('../', ''); } + if(module.indexOf("./") === 0 ) { + module = module.replace('./', ''); + } + for(var i = 0, j = modules.length ; i < j ; i++) { - if(module === modules[i].symbol || modules[i].symbol.indexOf(module) != -1) { - node.args[0].value = modules[i].path; - break; + var regx = new RegExp ("\\."+ module + "$"); + if(module === modules[i].symbol || modules[i].symbol.search(regx) != -1) { + node.args[0].value = modules[i].path; + break; } } }
