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/16 22:57:41 UTC
[2/3] git commit: Use events.emit instead of re-importing plugman
each time. Part 2.
Use events.emit instead of re-importing plugman each time. Part 2.
See details in 961ccd7cd22d43f4b75145d916afec395dd0db56
The first part added the change only under src/platforms/
this one changes it everywhere else.
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/c14f6b88
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/c14f6b88
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/c14f6b88
Branch: refs/heads/browserify
Commit: c14f6b88441924fa186fa76eb1fad37327bcf066
Parents: 961ccd7
Author: Mark Koudritsky <ka...@gmail.com>
Authored: Mon Apr 14 20:18:58 2014 -0400
Committer: Mark Koudritsky <ka...@gmail.com>
Committed: Mon Apr 14 20:18:58 2014 -0400
----------------------------------------------------------------------
src/fetch.js | 11 ++++++-----
src/util/action-stack.js | 13 +++++++------
src/util/plugins.js | 11 ++++++-----
src/util/w8jsproj.js | 11 ++++++-----
4 files changed, 25 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c14f6b88/src/fetch.js
----------------------------------------------------------------------
diff --git a/src/fetch.js b/src/fetch.js
index 5b245ad..9948b7f 100644
--- a/src/fetch.js
+++ b/src/fetch.js
@@ -3,6 +3,7 @@ var shell = require('shelljs'),
url = require('url'),
plugins = require('./util/plugins'),
xml_helpers = require('./util/xml-helpers'),
+ events = require('./events'),
metadata = require('./util/metadata'),
path = require('path'),
Q = require('q'),
@@ -42,7 +43,7 @@ module.exports = function fetchPlugin(plugin_src, plugins_dir, options) {
// If it looks like a network URL, git clone it.
if ( uri.protocol && uri.protocol != 'file:' && uri.protocol != 'c:' && !plugin_src.match(/^\w+:\\/)) {
- require('../plugman').emit('log', 'Fetching plugin "' + plugin_src + '" via git clone');
+ events.emit('log', 'Fetching plugin "' + plugin_src + '" via git clone');
if (options.link) {
return Q.reject(new Error('--link is not supported for git URLs'));
} else {
@@ -79,11 +80,11 @@ module.exports = function fetchPlugin(plugin_src, plugins_dir, options) {
var local_dir = findLocalPlugin(plugin_src, options.searchpath);
if (local_dir) {
p = Q(local_dir);
- require('../plugman').emit('verbose', 'Found ' + plugin_src + ' at ' + local_dir);
+ events.emit('verbose', 'Found ' + plugin_src + ' at ' + local_dir);
} else {
// If not found in local search path, fetch from the registry.
linkable = false;
- require('../plugman').emit('log', 'Fetching plugin "' + plugin_src + '" via plugin registry');
+ events.emit('log', 'Fetching plugin "' + plugin_src + '" via plugin registry');
p = registry.fetch([plugin_src], options.client);
}
}
@@ -155,11 +156,11 @@ function copyPlugin(plugin_dir, plugins_dir, link) {
var dest = path.join(plugins_dir, plugin_id);
shell.rm('-rf', dest);
if (link) {
- require('../plugman').emit('verbose', 'Linking plugin "' + plugin_dir + '" => "' + dest + '"');
+ events.emit('verbose', 'Linking plugin "' + plugin_dir + '" => "' + dest + '"');
fs.symlinkSync(plugin_dir, dest, 'dir');
} else {
shell.mkdir('-p', dest);
- require('../plugman').emit('verbose', 'Copying plugin "' + plugin_dir + '" => "' + dest + '"');
+ events.emit('verbose', 'Copying plugin "' + plugin_dir + '" => "' + dest + '"');
shell.cp('-R', path.join(plugin_dir, '*') , dest);
}
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c14f6b88/src/util/action-stack.js
----------------------------------------------------------------------
diff --git a/src/util/action-stack.js b/src/util/action-stack.js
index 3a5107a..dd9dafb 100644
--- a/src/util/action-stack.js
+++ b/src/util/action-stack.js
@@ -1,4 +1,5 @@
var platforms = require("../platforms"),
+ events = require('../events'),
Q = require('q'),
fs = require('fs');
@@ -25,12 +26,12 @@ ActionStack.prototype = {
},
// Returns a promise.
process:function(platform, project_dir) {
- require('../../plugman').emit('verbose', 'Beginning processing of action stack for ' + platform + ' project...');
+ events.emit('verbose', 'Beginning processing of action stack for ' + platform + ' project...');
var project_files;
// parse platform-specific project files once
if (platforms[platform].parseProjectFile) {
- require('../../plugman').emit('verbose', 'Parsing ' + platform + ' project files...');
+ events.emit('verbose', 'Parsing ' + platform + ' project files...');
project_files = platforms[platform].parseProjectFile(project_dir);
}
@@ -45,7 +46,7 @@ ActionStack.prototype = {
try {
handler.apply(null, action_params);
} catch(e) {
- require('../../plugman').emit('warn', 'Error during processing of action! Attempting to revert...');
+ events.emit('warn', 'Error during processing of action! Attempting to revert...');
var incomplete = this.stack.unshift(action);
var issue = 'Uh oh!\n';
// revert completed tasks
@@ -61,7 +62,7 @@ ActionStack.prototype = {
try {
revert.apply(null, revert_params);
} catch(err) {
- require('../../plugman').emit('warn', 'Error during reversion of action! We probably really messed up your project now, sorry! D:');
+ events.emit('warn', 'Error during reversion of action! We probably really messed up your project now, sorry! D:');
issue += 'A reversion action failed: ' + err.message + '\n';
}
}
@@ -70,10 +71,10 @@ ActionStack.prototype = {
}
this.completed.push(action);
}
- require('../../plugman').emit('verbose', 'Action stack processing complete.');
+ events.emit('verbose', 'Action stack processing complete.');
if (project_files) {
- require('../../plugman').emit('verbose', 'Writing out ' + platform + ' project files...');
+ events.emit('verbose', 'Writing out ' + platform + ' project files...');
project_files.write();
}
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c14f6b88/src/util/plugins.js
----------------------------------------------------------------------
diff --git a/src/util/plugins.js b/src/util/plugins.js
index 3801be7..7613169 100644
--- a/src/util/plugins.js
+++ b/src/util/plugins.js
@@ -26,6 +26,7 @@ var http = require('http'),
child_process = require('child_process'),
Q = require('q'),
xml_helpers = require('./xml-helpers'),
+ events = require('../events'),
tmp_dir;
module.exports = {
@@ -53,7 +54,7 @@ module.exports = {
shell.rm('-rf', tmp_dir);
var cmd = util.format('git clone "%s" "%s"', plugin_git_url, tmp_dir);
- require('../../plugman').emit('verbose', 'Fetching plugin via git-clone command: ' + cmd);
+ events.emit('verbose', 'Fetching plugin via git-clone command: ' + cmd);
var d = Q.defer();
child_process.exec(cmd, function(err, stdout, stderr) {
@@ -64,7 +65,7 @@ module.exports = {
}
});
return d.promise.then(function() {
- require('../../plugman').emit('verbose', 'Plugin "' + plugin_git_url + '" fetched.');
+ events.emit('verbose', 'Plugin "' + plugin_git_url + '" fetched.');
// Check out the specified revision, if provided.
if (git_ref) {
var cmd = util.format('git checkout "%s"', git_ref);
@@ -74,7 +75,7 @@ module.exports = {
else d2.resolve();
});
return d2.promise.then(function() {
- require('../../plugman').emit('log', 'Plugin "' + plugin_git_url + '" checked out to git ref "' + git_ref + '".');
+ events.emit('log', 'Plugin "' + plugin_git_url + '" checked out to git ref "' + git_ref + '".');
});
}
}).then(function() {
@@ -88,10 +89,10 @@ module.exports = {
// TODO: what if a plugin dependended on different subdirectories of the same plugin? this would fail.
// should probably copy over entire plugin git repo contents into plugins_dir and handle subdir seperately during install.
var plugin_dir = path.join(plugins_dir, plugin_id);
- require('../../plugman').emit('verbose', 'Copying fetched plugin over "' + plugin_dir + '"...');
+ events.emit('verbose', 'Copying fetched plugin over "' + plugin_dir + '"...');
shell.cp('-R', path.join(tmp_dir, '*'), plugin_dir);
- require('../../plugman').emit('verbose', 'Plugin "' + plugin_id + '" fetched.');
+ events.emit('verbose', 'Plugin "' + plugin_id + '" fetched.');
return plugin_dir;
});
}
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c14f6b88/src/util/w8jsproj.js
----------------------------------------------------------------------
diff --git a/src/util/w8jsproj.js b/src/util/w8jsproj.js
index a890429..692719e 100644
--- a/src/util/w8jsproj.js
+++ b/src/util/w8jsproj.js
@@ -7,6 +7,7 @@ var xml_helpers = require('./xml-helpers'),
et = require('elementtree'),
fs = require('fs'),
shell = require('shelljs'),
+ events = require('../events'),
path = require('path');
var WindowsStoreProjectTypeGUID = "{BC8A1FFA-BEE3-4634-8014-F334798102B3}"; // any of the below, subtype
@@ -16,7 +17,7 @@ var WinCplusplusProjectTypeGUID = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"; // .
function jsproj(location) {
- require('../../plugman').emit('verbose','creating jsproj from project at : ' + location);
+ events.emit('verbose','creating jsproj from project at : ' + location);
this.location = location;
this.xml = xml_helpers.parseElementtreeSync(location);
return this;
@@ -50,7 +51,7 @@ jsproj.prototype = {
addReference:function(relPath,src) {
- require('../../plugman').emit('verbose','addReference::' + relPath);
+ events.emit('verbose','addReference::' + relPath);
var item = new et.Element('ItemGroup');
var extName = path.extname(relPath);
@@ -76,7 +77,7 @@ jsproj.prototype = {
},
removeReference:function(relPath) {
- require('../../plugman').emit('verbose','removeReference::' + relPath);
+ events.emit('verbose','removeReference::' + relPath);
var extName = path.extname(relPath);
var includeText = path.basename(relPath,extName);
@@ -130,7 +131,7 @@ jsproj.prototype = {
},
// relative path must include the project file, so we can determine .csproj, .jsproj, .vcxproj...
addProjectReference:function(relative_path) {
- require('../../plugman').emit('verbose','adding project reference to ' + relative_path);
+ events.emit('verbose','adding project reference to ' + relative_path);
relative_path = relative_path.split('/').join('\\');
// read the solution path from the base directory
@@ -186,7 +187,7 @@ jsproj.prototype = {
},
removeProjectReference:function(relative_path) {
- require('../../plugman').emit('verbose','removing project reference to ' + relative_path);
+ events.emit('verbose','removing project reference to ' + relative_path);
// find the guid + name of the referenced project
var pluginProjectXML = xml_helpers.parseElementtreeSync(relative_path);