Merge pull request #10 from dpogue/github-url
Support git shortlink package references
diff --git a/index.js b/index.js
index 9d77f04..1316fce 100644
--- a/index.js
+++ b/index.js
@@ -84,7 +84,7 @@
})
.then(function (depTree) {
tree1 = depTree;
-
+ console.log(fetchArgs);
// install new module
return superspawn.spawn('npm', fetchArgs, opts);
})
@@ -99,7 +99,7 @@
// Need to use trimID in that case.
// This could happen on a platform update.
var id = getJsonDiff(tree1, tree2) || trimID(target);
-
+ console.log('id', id);
return module.exports.getPath(id, nodeModulesDir, target);
})
.fail(function (err) {
@@ -119,20 +119,31 @@
*
*/
function getJsonDiff (obj1, obj2) {
- var result = '';
-
+ var result = [];
+ console.log(obj1);
+ console.log(obj2);
// regex to filter out peer dependency warnings from result
var re = /UNMET PEER DEPENDENCY/;
for (var key in obj2) {
// if it isn't a unmet peer dependency, continue
if (key.search(re) === -1) {
- if (obj2[key] !== obj1[key]) result = key;
+ if (obj2[key] !== obj1[key]) {
+ console.log('key', key);
+ result.push(key);
+ }
}
}
- return result;
+ console.log(result);
+ console.log(result.length);
+ if (result.length > 1) {
+ console.log('result greater than 1');
+ //something went wrong if we have more than one module installed at a time
+ return false
+ }
+ // only return the first element
+ return result[0];
}
-
/*
* Takes the specified target and returns the moduleID
* If the git repoName is different than moduleID, then the
@@ -146,6 +157,7 @@
* @return {String} ID moduleID without version.
*/
function trimID (target) {
+ console.log('trimID', target);
var parts;
// If GITURL, set target to repo name
var gitInfo = hostedGitInfo.fromUrl(target);
@@ -200,7 +212,10 @@
function getPath (id, dest, target) {
var destination = path.resolve(path.join(dest, id));
+ console.log('dest', destination);
+ console.log(shell.ls(dest));
var finalDest = fs.existsSync(destination) ? destination : searchDirForTarget(dest, target);
+ console.log('finalDest', finalDest);
if (!finalDest) {
throw new CordovaError('Failed to get absolute path to installed module');