cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sgreb...@apache.org
Subject [01/13] git commit: CB-6481 Replaced CordovaError throwings with Error per @kamrik review Extracted prepareOptions Hooker method
Date Fri, 26 Sep 2014 21:20:00 GMT
Repository: cordova-lib
Updated Branches:
  refs/heads/master 8abfaf18c -> 57f454b28


CB-6481 Replaced CordovaError throwings with Error per @kamrik review
Extracted prepareOptions Hooker method


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

Branch: refs/heads/master
Commit: 35a350adecc6daa04af42c9ef42f318ca862383f
Parents: 4f0e74f
Author: daserge <daserge@yandex.ru>
Authored: Tue Jul 15 14:51:15 2014 +0400
Committer: daserge <daserge@yandex.ru>
Committed: Thu Sep 25 18:59:08 2014 +0400

----------------------------------------------------------------------
 cordova-lib/src/hooks/Hooker.js        | 21 ++++++++++++++-------
 cordova-lib/src/hooks/ScriptsFinder.js |  7 +++----
 cordova-lib/src/hooks/ScriptsRunner.js |  3 +--
 3 files changed, 18 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/35a350ad/cordova-lib/src/hooks/Hooker.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/hooks/Hooker.js b/cordova-lib/src/hooks/Hooker.js
index 9951e20..7d50e76 100644
--- a/cordova-lib/src/hooks/Hooker.js
+++ b/cordova-lib/src/hooks/Hooker.js
@@ -22,8 +22,7 @@ var util  = require('../cordova/util'),
     plugin  = require('../cordova/plugin'),
     ScriptsFinder = require('./ScriptsFinder'),
     ScriptsRunner = require('./ScriptsRunner'),
-    Context = require('./Context'),
-    CordovaError = require('../CordovaError');
+    Context = require('./Context');
 
 /**
  * Tries to create a hooker for passed project root.
@@ -31,7 +30,7 @@ var util  = require('../cordova/util'),
  */
 function Hooker(projectRoot) {
     if (!util.isCordova(projectRoot)) {
-        throw new CordovaError('Not a Cordova project ("' + projectRoot + '"), can\'t use
hooks.');
+        throw new Error('Not a Cordova project ("' + projectRoot + '"), can\'t use hooks.');
     }
 }
 
@@ -42,12 +41,10 @@ function Hooker(projectRoot) {
 Hooker.prototype.fire = function fire(hook, opts) {
     // args check
     if (!hook) {
-        throw new CordovaError('hook type is not specified');
+        throw new Error('hook type is not specified');
     }
     // execute hook event listeners first
-    return setPluginsProperty(opts).then(function(){
-        setCordovaVersionProperty(opts);
-
+    return this.prepareOptions(opts).then(function(){
         var handlers = events.listeners(hook);
         return executeHandlersSerially(handlers, opts);
     // then execute hook script files
@@ -59,6 +56,16 @@ Hooker.prototype.fire = function fire(hook, opts) {
 };
 
 /**
+ * Set all unset options.
+ * Returns a promise.
+ */
+Hooker.prototype.prepareOptions = function(opts) {
+    return setPluginsProperty(opts).then(function() {
+        setCordovaVersionProperty(opts);
+    });
+};
+
+/**
  * Sets hook options cordova.plugins list if it was not set.
  * Returns a promise.
  */

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/35a350ad/cordova-lib/src/hooks/ScriptsFinder.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/hooks/ScriptsFinder.js b/cordova-lib/src/hooks/ScriptsFinder.js
index 5fb9ed2..f9659de 100644
--- a/cordova-lib/src/hooks/ScriptsFinder.js
+++ b/cordova-lib/src/hooks/ScriptsFinder.js
@@ -25,7 +25,6 @@ var path = require('path'),
     plugin  = require('../cordova/plugin'),
     PluginInfo = require('../PluginInfo'),
     ConfigParser = require('../configparser/ConfigParser'),
-    CordovaError = require('../CordovaError'),
     Context = require('./Context');
 
 /**
@@ -39,7 +38,7 @@ module.exports  = {
     getHookScripts: function(hook, opts) {
         // args check
         if (!hook) {
-            throw new CordovaError('hook type is not specified');
+            throw new Error('hook type is not specified');
         }
         return getApplicationHookScripts(hook, opts)
             .concat(getPluginsHookScripts(hook, opts));
@@ -53,7 +52,7 @@ module.exports  = {
 function getApplicationHookScripts(hook, opts) {
     // args check
     if (!hook) {
-        throw new CordovaError('hook type is not specified');
+        throw new Error('hook type is not specified');
     }
     return getApplicationHookScriptsFromDir(path.join(opts.projectRoot, '.cordova', 'hooks',
hook))
         .concat(getApplicationHookScriptsFromDir(path.join(opts.projectRoot, 'hooks', hook)))
@@ -66,7 +65,7 @@ function getApplicationHookScripts(hook, opts) {
 function getPluginsHookScripts(hook, opts) {
     // args check
     if (!hook) {
-        throw new CordovaError('hook type is not specified');
+        throw new Error('hook type is not specified');
     }
 
     // In case before_plugin_install, after_plugin_install, before_plugin_uninstall hooks
we receive opts.plugin and

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/35a350ad/cordova-lib/src/hooks/ScriptsRunner.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/hooks/ScriptsRunner.js b/cordova-lib/src/hooks/ScriptsRunner.js
index c7ff70d..918b56d 100644
--- a/cordova-lib/src/hooks/ScriptsRunner.js
+++ b/cordova-lib/src/hooks/ScriptsRunner.js
@@ -22,7 +22,6 @@ var Q = require('q'),
     os = require('os'),
     path = require('path'),
     superspawn = require('../cordova/superspawn'),
-    CordovaError = require('../CordovaError'),
     Context = require('./Context');
 
 var isWindows = os.platform().slice(0, 3) === 'win';
@@ -125,7 +124,7 @@ function runScriptViaChildProcessSpawn(script, context) {
             if (!isWindows && err.code == 'EACCES') {
                 events.emit('verbose', 'skipped non-executable file: ' + script.fullPath);
             } else {
-                throw new CordovaError('Hook failed with error code ' + err.code + ': ' +
script.fullPath);
+                throw new Error('Hook failed with error code ' + err.code + ': ' + script.fullPath);
             }
         });
 }


Mime
View raw message