You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2014/04/24 23:11:28 UTC
[43/45] js commit: adding case for org.apache.cordova.* modules
adding case for org.apache.cordova.* modules
Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/7d1233f8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/7d1233f8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/7d1233f8
Branch: refs/heads/master
Commit: 7d1233f870c3050a71d2b0e9648bffc82cc02a7a
Parents: 40c4ab4
Author: Anis Kadri <an...@apache.org>
Authored: Sat Mar 29 21:15:06 2014 +0100
Committer: Anis Kadri <an...@apache.org>
Committed: Sat Mar 29 21:15:06 2014 +0100
----------------------------------------------------------------------
tasks/lib/require-tr.js | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/7d1233f8/tasks/lib/require-tr.js
----------------------------------------------------------------------
diff --git a/tasks/lib/require-tr.js b/tasks/lib/require-tr.js
index 7bde0f6..8964aee 100644
--- a/tasks/lib/require-tr.js
+++ b/tasks/lib/require-tr.js
@@ -51,15 +51,22 @@ var requireTr = {
return through(write, end);
},
- getSymbolList: function() {
- return this.symbolList;
+ getModules: function() {
+ return this.modules;
+ },
+ addModule: function(module) {
+ if(!module || !module.symbol || !module.path) {
+ throw new Error("Can't add module without a symbol and a path");
+ }
+ this.modules.push(module);
},
platform: null,
- symbolList: []
+ modules: []
+
}
/*
- * visits AST and modifies all the require('cordova/*')
+ * visits AST and modifies all the require('cordova/*') and require('org.apache.cordova.*')
*/
function _updateRequires(code) {
@@ -84,11 +91,11 @@ function _updateRequires(code) {
// require('cordova') -> cordova.js
if(module === "cordova") {
node.args[0].value = path.join(root, "src", "cordova_b");
- // android and amazon-fireos have some special require's
+ // require('cordova/init') -> common/init
} else if(module.match(/cordova\/init/)) {
node.args[0].value = module.replace(/cordova\/init/,
path.join(root, "src", "common", "init_b"));
- // require('cordova/exec') and require('cordova/platform') -> platform's exec/platform
+ // android and amazon-fireos have some special require's
} else if(module.match(/cordova\/(android|amazon-fireos)\/(.+)/)) {
node.args[0].value = module.replace(/cordova\/(android|amazon-fireos)\/(.+)/,
path.join(root, "src", "$1", "android", "$2"));
@@ -101,6 +108,14 @@ function _updateRequires(code) {
node.args[0].value = module.replace(/cordova\/(.+)/,
path.join(root, "src", "common", "$1"));
}
+ } else if(module !== undefined && module.indexOf("org.apache.cordova") !== -1 ) {
+ var modules = requireTr.getModules();
+ for(var i = 0, j = modules.length ; i < j ; i++) {
+ if(module.match(modules[i].symbol)) {
+ node.args[0].value = modules[i].path;
+ break;
+ }
+ }
}
}
}