cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [3/5] js commit: CB-9156 added support for absolute platform paths
Date Sat, 20 Jun 2015 01:45:52 GMT
CB-9156 added support for absolute platform paths


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/d88c18b6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/d88c18b6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/d88c18b6

Branch: refs/heads/master
Commit: d88c18b6aab74d3b9f527adeec03093286657326
Parents: 3e13d0a
Author: Steve Gill <stevengill97@gmail.com>
Authored: Fri Jun 19 18:08:53 2015 -0700
Committer: Steve Gill <stevengill97@gmail.com>
Committed: Fri Jun 19 18:44:37 2015 -0700

----------------------------------------------------------------------
 README.md                   |  4 +++-
 package.json                |  3 ++-
 tasks/compile-browserify.js |  5 +++--
 tasks/compile.js            | 25 +++++++++++++++----------
 tasks/lib/bundle.js         | 19 +++++--------------
 5 files changed, 28 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d88c18b6/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 6c74955..13c6933 100644
--- a/README.md
+++ b/README.md
@@ -71,7 +71,7 @@ To compile the js for just one platform, run:
 
     grunt compile:android --platformVersion=4.0.0
 
-To comiple the js for all platforms but pass in a relative path custom root for your cordova-android
and cordova-ios platforms, run:
+To comiple the js for all platforms but pass in a custom path for your cordova-android and
cordova-ios platforms, run:
 
     grunt compile --android='../custompath/cordova-android' --ios='../custompath/cordova-ios'
 
@@ -83,6 +83,8 @@ To compile the browserify version of the js for just one platform, run:
 
     grunt compile-browserify:android --platformVersion=4.0.0
 
+NOTE: browserify method does not support custom paths for platform repos.
+
 For integration, see the 'Integration' section below.
 
 ## Known Issues

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d88c18b6/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index f7f712d..ac795aa 100644
--- a/package.json
+++ b/package.json
@@ -88,6 +88,7 @@
     "cordova-wp8": "../cordova-wp8",
     "cordova-windows": "../cordova-windows",
     "cordova-osx": "../cordova-osx",
-    "cordova-browser": "../cordova-browser"
+    "cordova-browser": "../cordova-browser",
+    "cordova-webos": "../cordova-webos"
   }
 }

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d88c18b6/tasks/compile-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/compile-browserify.js b/tasks/compile-browserify.js
index 3ce4554..034acdc 100644
--- a/tasks/compile-browserify.js
+++ b/tasks/compile-browserify.js
@@ -45,8 +45,9 @@ module.exports = function(grunt) {
             }
         });
         if(!platformVersion){
-            if(pkgJson['cordova-platforms']['cordova-'+platformName] && fs.existsSync(path.join(pkgJson['cordova-platforms']['cordova-'+platformName])))
{
-                var platformPkgJson = require('../' + pkgJson['cordova-platforms']['cordova-'+platformName]
+'/package.json');
+            var platformPath = pkgJson['cordova-platforms']['cordova-'+platformName];
+            if(platformPath && fs.existsSync(platformPath)) {
+                var platformPkgJson = require('../' + platformPath +'/package.json');
                 platformVersion = platformPkgJson.version;
             } else {
                 console.log('platformVersion not supplied. Setting platformVersion to N/A');

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d88c18b6/tasks/compile.js
----------------------------------------------------------------------
diff --git a/tasks/compile.js b/tasks/compile.js
index 9cd5e24..187cb27 100644
--- a/tasks/compile.js
+++ b/tasks/compile.js
@@ -19,40 +19,45 @@
 var generate = require('./lib/packager');
 var fs = require('fs');
 var path = require('path');
-var pkgJson = require(process.cwd() + '/package.json');
+var pkgJson = require('../package.json');
 
 module.exports = function(grunt) {
     grunt.registerMultiTask('compile', 'Packages cordova.js', function() {
         var done = this.async();
         var platformName = this.target;
         var useWindowsLineEndings = this.data.useWindowsLineEndings;
-        var platformVersion;
        
         //grabs --platformVersion flag
         var flags = grunt.option.flags();
         var platformVersion;
         var platformPath = undefined;
         flags.forEach(function(flag) {
+            //see if --platformVersion was passed in
             if (flag.indexOf('platformVersion') > -1) {
                 var equalIndex = flag.indexOf('=');
                 platformVersion = flag.slice(equalIndex + 1);
             }
-
+            
+            //see if flags for platforms were passed in
+            //followed by custom paths
             if (flag.indexOf(platformName) > -1) {
                 var equalIndex = flag.indexOf('=');
                 platformPath = flag.slice(equalIndex + 1);
             }
         });
+        //Use platformPath from package.json, no custom platform path
+        if(platformPath === undefined) { 
+            platformPath = pkgJson['cordova-platforms']['cordova-'+platformName];
+        }
+        //Get absolute path to platform
+        if(platformPath) {
+            platformPath = path.resolve(platformPath);
+        }
         if(!platformVersion) {
             var platformPkgJson;
-            //grab platformVersion from custom path
-            if(platformPath && fs.existsSync(platformPath)) {
-                platformPkgJson = require('../' + platformPath + '/package.json');
-                platformVersion = platformPkgJson.version;
 
-            //grab platformVersion from sibling platform directoreis
-            } else if(pkgJson['cordova-platforms']['cordova-'+platformName] && fs.existsSync(path.join(pkgJson['cordova-platforms']['cordova-'+platformName])))
{
-                platformPkgJson = require('../' + pkgJson['cordova-platforms']['cordova-'+platformName]+'/package.json');
+            if(platformPath && fs.existsSync(platformPath)) {
+                platformPkgJson = require(platformPath +'/package.json');
                 platformVersion = platformPkgJson.version;
             } else {
                 platformVersion="N/A";

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d88c18b6/tasks/lib/bundle.js
----------------------------------------------------------------------
diff --git a/tasks/lib/bundle.js b/tasks/lib/bundle.js
index 34bffeb..2d81591 100644
--- a/tasks/lib/bundle.js
+++ b/tasks/lib/bundle.js
@@ -23,7 +23,7 @@ var copyProps    = require('./copy-props');
 var writeModule  = require('./write-module');
 var writeScript  = require('./write-script');
 var licensePath  = path.join(__dirname, '..', 'templates', 'LICENSE-for-js-file.txt');
-var pkgJson      = require(process.cwd()+'/package.json');
+var pkgJson      = require('../../package.json');
 
 module.exports = function bundle(platform, debug, commitId, platformVersion, platformPath)
{
     var modules = collectFiles(path.join('src', 'common'));
@@ -31,19 +31,9 @@ module.exports = function bundle(platform, debug, commitId, platformVersion,
pla
     var platformDep;
     modules[''] = path.join('src', 'cordova.js');
 
-    //Use passed in platformPath if it exists
-    if(platformPath) {
-        platformDep = path.join(process.cwd(), platformPath);
-    //see if platform location exists in package.json
-    } else if(pkgJson['cordova-platforms']['cordova-'+platform]){
-        platformDep = path.join(process.cwd(), pkgJson['cordova-platforms']['cordova-'+platform]);
-    } else {
-        platformDep = undefined;
-    }
-
-    //check to see if platform dependency has cordova-js-src directory
-    if(fs.existsSync(platformDep) && fs.existsSync(path.join(platformDep, 'cordova-js-src')))
{
-        copyProps(modules, collectFiles(path.join(platformDep, 'cordova-js-src')));
+    //check to see if platform has cordova-js-src directory
+    if(fs.existsSync(platformPath) && fs.existsSync(path.join(platformPath, 'cordova-js-src')))
{
+        copyProps(modules, collectFiles(path.join(platformPath, 'cordova-js-src')));
     } else {
         if(platform !== 'test') {
             //for platforms that don't have a release with cordova-js-src yet
@@ -54,6 +44,7 @@ module.exports = function bundle(platform, debug, commitId, platformVersion,
pla
         }
 
     }
+    //test doesn't support custom paths
     if (platform === 'test') {
         var testFilesPath;
         // Add android platform-specific modules that have tests to the test bundle.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message