You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by br...@apache.org on 2013/05/10 20:39:10 UTC
[2/4] git commit: Adding subdirectory support to fetch.
Adding subdirectory support to fetch.
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/7d2cd7d5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/7d2cd7d5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/7d2cd7d5
Branch: refs/heads/dependencies
Commit: 7d2cd7d5798db71886b6f3a47653a585edb187f1
Parents: 5e9eebb
Author: Braden Shepherdson <br...@gmail.com>
Authored: Thu May 9 12:54:57 2013 -0400
Committer: Braden Shepherdson <br...@gmail.com>
Committed: Thu May 9 12:54:57 2013 -0400
----------------------------------------------------------------------
spec/util/plugins.spec.js | 4 ++--
src/fetch.js | 11 +++++++----
src/install.js | 2 +-
src/util/plugins.js | 5 +++--
4 files changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/7d2cd7d5/spec/util/plugins.spec.js
----------------------------------------------------------------------
diff --git a/spec/util/plugins.spec.js b/spec/util/plugins.spec.js
index 55c3f0e..f0cb3e0 100644
--- a/spec/util/plugins.spec.js
+++ b/spec/util/plugins.spec.js
@@ -32,10 +32,10 @@ describe('plugins', function(){
var plugin_git_url = 'https://github.com/imhotep/ChildBrowser'
var myFunction = function(){};
- plugins.clonePluginGitRepo(plugin_git_url, temp, myFunction);
+ plugins.clonePluginGitRepo(plugin_git_url, temp, '.', myFunction);
expect(mySpy).toHaveBeenCalled();
- expect(mySpy).toHaveBeenCalledWith(plugin_git_url, temp, myFunction);
+ expect(mySpy).toHaveBeenCalledWith(plugin_git_url, temp, '.', myFunction);
});
});
});
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/7d2cd7d5/src/fetch.js
----------------------------------------------------------------------
diff --git a/src/fetch.js b/src/fetch.js
index 822f28d..8d6c7b8 100644
--- a/src/fetch.js
+++ b/src/fetch.js
@@ -4,10 +4,12 @@ var shell = require('shelljs'),
xml_helpers = require('./util/xml-helpers'),
path = require('path');
-module.exports = function fetchPlugin(plugin_dir, plugins_dir, link, callback) {
+module.exports = function fetchPlugin(plugin_dir, plugins_dir, link, subdir, callback) {
// Ensure the containing directory exists.
shell.mkdir('-p', plugins_dir);
+ subdir = subdir || '.';
+
// clone from git repository
if(plugin_dir.indexOf('https://') == 0 || plugin_dir.indexOf('git://') == 0) {
if (link) {
@@ -15,11 +17,12 @@ module.exports = function fetchPlugin(plugin_dir, plugins_dir, link, callback) {
if (callback) callback(err);
else throw err;
} else {
- plugins.clonePluginGitRepo(plugin_dir, plugins_dir, callback);
+ plugins.clonePluginGitRepo(plugin_dir, plugins_dir, subdir, callback);
}
} else {
// Copy from the local filesystem.
// First, read the plugin.xml and grab the ID.
+ plugin_dir = path.join(plugin_dir, subdir);
var xml = xml_helpers.parseElementtreeSync(path.join(plugin_dir, 'plugin.xml'));
var plugin_id = xml.getroot().attrib.id;
@@ -27,9 +30,9 @@ module.exports = function fetchPlugin(plugin_dir, plugins_dir, link, callback) {
shell.rm('-rf', dest);
if (link) {
- fs.symlinkSync(path.resolve(plugin_dir), dest, 'dir');
+ fs.symlinkSync(plugin_dir, dest, 'dir');
} else {
- shell.cp('-R', path.join(plugin_dir, '*'), dest);
+ shell.cp('-R', plugin_dir, dest);
}
if (callback) callback(null, dest);
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/7d2cd7d5/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index 617b065..257d8de 100644
--- a/src/install.js
+++ b/src/install.js
@@ -20,7 +20,7 @@ module.exports = function installPlugin(platform, project_dir, name, plugins_dir
// Check that the plugin has already been fetched.
if (!fs.existsSync(plugin_dir)) {
// if plugin doesnt exist, use fetch to get it.
- require('../plugman').fetch(name, plugins_dir, false, function(err, plugin_dir) {
+ require('../plugman').fetch(name, plugins_dir, false, '.', function(err, plugin_dir) {
if (err) {
callback(err);
} else {
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/7d2cd7d5/src/util/plugins.js
----------------------------------------------------------------------
diff --git a/src/util/plugins.js b/src/util/plugins.js
index 0a627cb..fddecfa 100644
--- a/src/util/plugins.js
+++ b/src/util/plugins.js
@@ -25,12 +25,12 @@ var http = require('http'),
util = require('util'),
shell = require('shelljs'),
xml_helpers = require('./xml-helpers'),
- tmp_dir = path.join(path.sep, 'tmp', 'plugman-tmp');
+ tmp_dir = path.join(os.tmpdir(), 'plugman-tmp');
module.exports = {
searchAndReplace:require('./search-and-replace'),
// Fetches plugin information from remote server
- clonePluginGitRepo:function(plugin_git_url, plugins_dir, callback) {
+ clonePluginGitRepo:function(plugin_git_url, plugins_dir, subdir, callback) {
if(!shell.which('git')) {
var err = new Error('git command line is not installed');
if (callback) callback(err);
@@ -47,6 +47,7 @@ module.exports = {
else throw err;
} else {
// Read the plugin.xml file and extract the plugin's ID.
+ tmp_dir = path.join(tmp_dir, subdir);
var xml_file = path.join(tmp_dir, 'plugin.xml');
var xml = xml_helpers.parseElementtreeSync(xml_file);
var plugin_id = xml.getroot().attrib.id;