cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kam...@apache.org
Subject git commit: CB-6767 Allow `cordova` to be replaceable
Date Thu, 29 May 2014 18:58:47 GMT
Repository: cordova-lib
Updated Branches:
  refs/heads/master 9dc05de9c -> 39327db7d


CB-6767 Allow `cordova` to be replaceable

Allow to specify the name of the binary for phrasing error and warning messages
with the proper binary name.

github: close #20


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

Branch: refs/heads/master
Commit: 39327db7d126959a358cd26ea438ac2e3bfd7ceb
Parents: 9dc05de
Author: Josh Soref <jsoref@blackberry.com>
Authored: Tue May 27 13:22:39 2014 -0400
Committer: Mark Koudritsky <kamrik@gmail.com>
Committed: Thu May 29 14:58:05 2014 -0400

----------------------------------------------------------------------
 cordova-lib/cordova-lib.js          | 20 +++++++++++++-------
 cordova-lib/src/cordova/cordova.js  |  2 ++
 cordova-lib/src/cordova/create.js   |  6 +++---
 cordova-lib/src/cordova/platform.js | 10 +++++-----
 cordova-lib/src/cordova/plugin.js   | 10 +++++-----
 cordova-lib/src/cordova/util.js     |  3 ++-
 6 files changed, 30 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/39327db7/cordova-lib/cordova-lib.js
----------------------------------------------------------------------
diff --git a/cordova-lib/cordova-lib.js b/cordova-lib/cordova-lib.js
index 5364c71..9d7d9d8 100644
--- a/cordova-lib/cordova-lib.js
+++ b/cordova-lib/cordova-lib.js
@@ -18,13 +18,19 @@
 */
 
 // For now expose plagman and cordova just as they were in the old repos
-exports.plugman = require('./src/plugman/plugman');
-exports.cordova = require('./src/cordova/cordova');
-exports.cordova_platforms = require('./src/cordova/platforms');
-
-
-////  MAIN CORDOVA TOOLS API
-exports.CordovaError = require('./src/CordovaError');
+exports = module.exports = {
+    set binname(name) {
+        this.cordova.binname = name;
+    },
+    get binname() {
+       return this.cordova.binname;
+    },
+    plugman: require('./src/plugman/plugman'),
+    cordova: require('./src/cordova/cordova'),
+    cordova_platforms: require('./src/cordova/platforms'),
+    ////  MAIN CORDOVA TOOLS API
+    CordovaError: require('./src/CordovaError')
+}
 
 
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/39327db7/cordova-lib/src/cordova/cordova.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/cordova.js b/cordova-lib/src/cordova/cordova.js
index 6fcb05e..bb21f07 100644
--- a/cordova-lib/src/cordova/cordova.js
+++ b/cordova-lib/src/cordova/cordova.js
@@ -28,6 +28,8 @@ var emit = function() {
 };
 
 exports = module.exports = {
+    get binname() { return cordova_util.binname; },
+    set binname(name) { cordova_util.binname = name; },
     on:        function() {
         cordova_events.on.apply(cordova_events, arguments);
     },

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/39327db7/cordova-lib/src/cordova/create.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/create.js b/cordova-lib/src/cordova/create.js
index f721901..b846c20 100644
--- a/cordova-lib/src/cordova/create.js
+++ b/cordova-lib/src/cordova/create.js
@@ -27,7 +27,7 @@ var path          = require('path'),
     Q             = require('q'),
     CordovaError  = require('../CordovaError'),
     ConfigParser = require('./ConfigParser'),
-    util          = require('./util');
+    cordova_util  = require('./util');
 
 var DEFAULT_NAME = "HelloCordova",
     DEFAULT_ID   = "io.cordova.hellocordova";
@@ -44,7 +44,7 @@ module.exports = create;
 function create(dir, id, name, cfg) {
     if (!dir ) {
         return Q.reject(new CordovaError(
-            'At least the dir must be provided to create new project. See `corova help`.'
+            'At least the dir must be provided to create new project. See `'+cordova_util.binname+'
help`.'
         ));
     }
 
@@ -203,7 +203,7 @@ function create(dir, id, name, cfg) {
         // Add hooks README.md
         shell.cp(path.join(__dirname, '..', '..', 'templates', 'hooks-README.md'), path.join(dir,
'hooks', 'README.md'));
 
-        var configPath = util.projectConfig(dir);
+        var configPath = cordova_util.projectConfig(dir);
         // Add template config.xml for apps that are missing it
         if (!fs.existsSync(configPath)) {
             var template_config_xml = path.join(__dirname, '..', '..', 'templates', 'config.xml');

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/39327db7/cordova-lib/src/cordova/platform.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platform.js b/cordova-lib/src/cordova/platform.js
index dcba97e..b69bb34 100644
--- a/cordova-lib/src/cordova/platform.js
+++ b/cordova-lib/src/cordova/platform.js
@@ -49,7 +49,7 @@ function add(hooks, projectRoot, targets, opts) {
     var xml = cordova_util.projectConfig(projectRoot);
     var cfg = new ConfigParser(xml);
     if (!targets || !targets.length) {
-        return Q.reject(new CordovaError('No platform specified. Please specify a platform
to add. See "platform list".'));
+        return Q.reject(new CordovaError('No platform specified. Please specify a platform
to add. See `'+cordova_util.binname+' platform list`.'));
     }
     var config_json = config.read(projectRoot);
     var platformsDir = path.join(projectRoot, 'platforms');
@@ -85,7 +85,7 @@ function add(hooks, projectRoot, targets, opts) {
 
 function remove(hooks, projectRoot, targets, opts) {
     if (!targets || !targets.length) {
-        return Q.reject(new CordovaError('No platform[s] specified. Please specify platform[s]
to remove. See "platform list".'));
+        return Q.reject(new CordovaError('No platform[s] specified. Please specify platform[s]
to remove. See `'+cordova_util.binname+' platform list`.'));
     }
     return hooks.fire('before_platform_rm', opts)
     .then(function() {
@@ -102,7 +102,7 @@ function remove(hooks, projectRoot, targets, opts) {
 function update(hooks, projectRoot, targets, opts) {
     // Shell out to the update script provided by the named platform.
     if (!targets || !targets.length) {
-        return Q.reject(new CordovaError('No platform specified. Please specify a platform
to update. See "platform list".'));
+        return Q.reject(new CordovaError('No platform specified. Please specify a platform
to update. See `'+cordova_util.binname+' platform list`.'));
     } else if (targets.length > 1) {
         return Q.reject(new CordovaError('Platform update can only be executed on one platform
at a time.'));
     } else {
@@ -110,7 +110,7 @@ function update(hooks, projectRoot, targets, opts) {
         var platformPath = path.join(projectRoot, 'platforms', plat);
         var installed_platforms = cordova_util.listPlatforms(projectRoot);
         if (installed_platforms.indexOf(plat) < 0) {
-            return Q.reject(new CordovaError('Platform "' + plat + '" is not installed. See
"platform list".'));
+            return Q.reject(new CordovaError('Platform "' + plat + '" is not installed. See
`'+cordova_util.binname+' platform list`.'));
         }
 
         function copyCordovaJs() {
@@ -264,7 +264,7 @@ module.exports = function platform(command, targets) {
         var err;
         targets.forEach(function(t) {
             if (!(t in platforms)) {
-                err = new CordovaError('Platform "' + t + '" not recognized as a core cordova
platform. See "platform list".');
+                err = new CordovaError('Platform "' + t + '" not recognized as a core cordova
platform. See `'+cordova_util.binname+' platform list`.');
             }
         });
         if (err) return Q.reject(err);

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/39327db7/cordova-lib/src/cordova/plugin.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/plugin.js b/cordova-lib/src/cordova/plugin.js
index 06433e9..a04e979 100644
--- a/cordova-lib/src/cordova/plugin.js
+++ b/cordova-lib/src/cordova/plugin.js
@@ -66,7 +66,7 @@ module.exports = function plugin(command, targets, opts) {
     plugins = cordova_util.findPlugins(pluginPath);
     if (!targets || !targets.length) {
         if (command == 'add' || command == 'rm') {
-            return Q.reject(new CordovaError('You need to qualify `add` or `remove` with
one or more plugins!'));
+            return Q.reject(new CordovaError('You need to qualify `'+cordova_util.binname+'
plugin add` or `'+cordova_util.binname+' plugin remove` with one or more plugins!'));
         } else {
             targets = [];
         }
@@ -87,7 +87,7 @@ module.exports = function plugin(command, targets, opts) {
     switch(command) {
         case 'add':
             if (!targets || !targets.length) {
-                return Q.reject(new CordovaError('No plugin specified. Please specify a plugin
to add. See "plugin search".'));
+                return Q.reject(new CordovaError('No plugin specified. Please specify a plugin
to add. See `'+cordova_util.binname+' plugin search`.'));
             }
 
             var config_json = config(projectRoot, {});
@@ -154,14 +154,14 @@ module.exports = function plugin(command, targets, opts) {
         case 'rm':
         case 'remove':
             if (!targets || !targets.length) {
-                return Q.reject(new CordovaError('No plugin specified. Please specify a plugin
to remove. See "plugin list".'));
+                return Q.reject(new CordovaError('No plugin specified. Please specify a plugin
to remove. See `'+cordova_util.binname+' plugin list`.'));
             }
             return hooks.fire('before_plugin_rm', opts)
             .then(function() {
                 return opts.plugins.reduce(function(soFar, target) {
                     // Check if we have the plugin.
                     if (plugins.indexOf(target) < 0) {
-                        return Q.reject(new CordovaError('Plugin "' + target + '" is not
present in the project. See "plugin list".'));
+                        return Q.reject(new CordovaError('Plugin "' + target + '" is not
present in the project. See `'+cordova_util.binname+' plugin list`.'));
                     }
 
                     var targetPath = path.join(pluginPath, target);
@@ -224,7 +224,7 @@ function list(projectRoot, hooks) {
     })
     .then(function(plugins) {
         if (plugins.length === 0) {
-            events.emit('results', 'No plugins added. Use `cordova plugin add <plugin>`.');
+            events.emit('results', 'No plugins added. Use `'+cordova_util.binname+' plugin
add <plugin>`.');
             return;
         }
         var pluginsDict = {};

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/39327db7/cordova-lib/src/cordova/util.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/util.js b/cordova-lib/src/cordova/util.js
index 6b1751b..7ea3fff 100644
--- a/cordova-lib/src/cordova/util.js
+++ b/cordova-lib/src/cordova/util.js
@@ -46,6 +46,7 @@ function isRootDir(dir) {
 }
 
 exports = module.exports = {
+    binname: 'cordova',
     globalConfig:global_config_path,
     libDirectory:lib_path,
     // Runs up the directory chain looking for a .cordova directory.
@@ -167,7 +168,7 @@ exports = module.exports = {
         }
         var projectPlatforms = this.listPlatforms(projectRoot);
         if (projectPlatforms.length === 0) {
-            throw new CordovaError('No platforms added to this project. Please use `cordova
platform add <platform>`.');
+            throw new CordovaError('No platforms added to this project. Please use `'+exports.binname+'
platform add <platform>`.');
         }
         if (result.platforms.length === 0) {
             result.platforms = projectPlatforms;


Mime
View raw message