From f4567605c5309ff1925691cb79360572f4fd5be5 Mon Sep 17 00:00:00 2001 From: Raif Harik Date: Sun, 6 Sep 2015 16:27:21 -0500 Subject: [PATCH 1/2] adding support for github dependencies --- .idea/.name | 1 + .idea/misc.xml | 14 +++ .idea/modules.xml | 8 ++ .idea/npm-install-missing.iml | 8 ++ .idea/vcs.xml | 6 + .idea/workspace.xml | 220 ++++++++++++++++++++++++++++++++++ index.js | 11 +- test/run.js | 55 ++++++++- 8 files changed, 318 insertions(+), 5 deletions(-) create mode 100644 .idea/.name create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/npm-install-missing.iml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..6b60547 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +npm-install-missing \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..19f74da --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..f8014aa --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/npm-install-missing.iml b/.idea/npm-install-missing.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/npm-install-missing.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..52d0cba --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1441573087115 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/index.js b/index.js index 4891f33..d798cc5 100644 --- a/index.js +++ b/index.js @@ -14,8 +14,11 @@ NpmRetryInstall.getMissing = function(path, cb){ if (err) throw err; var missing_modules = []; data.forEach(function(module){ - if(module[2] === undefined) - missing_modules.push([module[1], module[3]]); + if (module[2] === undefined) + if (module[3] === 'git') + missing_modules.push([module[1], module[5]]); + else + missing_modules.push([module[1], module[3]]); }); cb(missing_modules); }); @@ -36,7 +39,7 @@ NpmRetryInstall.init = function(cb){ NpmRetryInstall.getMissing(process.cwd(), function(data){ if(data.length > 0){ console.log(data); - + async.map(data, NpmRetryInstall.installModule, function(err, result){ result.forEach(function(module){ msg.push(module[0] + "@" + module[1]); @@ -47,4 +50,4 @@ NpmRetryInstall.init = function(cb){ cb('No modules seem to be missing. Huzzah!'); } }); -}; \ No newline at end of file +}; diff --git a/test/run.js b/test/run.js index a7a7e02..9de7811 100644 --- a/test/run.js +++ b/test/run.js @@ -116,4 +116,57 @@ describe('npm-install-missing', function(){ }); }); -}); \ No newline at end of file +}); + + +describe('npm-install-missing', function(){ + this.timeout(10000); + before(function(done){ + fake_package_json.dependencies = { "npm-install-missing":"git+https://github.com/AlexCline/npm-install-missing.git" }; + mkdirp(working_dir, function(err){ + if (err) throw err; + try { + process.chdir(working_dir); + fs.writeFile(working_dir + '/package.json', JSON.stringify(fake_package_json, null, 2), function(err){ + if (err) throw err; + exec('rm -rf ' + working_dir + '/node_modules', function(err, result){ + if (err) throw err; + done(); + }); + }); + } + catch (err) { + console.log('chdir: ' + err); + } + }); + }); + + after(function(done){ + fake_package_json.dependencies = test_dependency; + exec('rm -rf ' + working_dir, function(err, result){ + if(err) throw err; + done(); + }); + }); + + describe('#getMissing()', function(){ + it('should get a list of the missing modules when moduel is from git before anything is installed', function(done){ + npm_install_missing.getMissing(process.cwd(), function(data){ + assert.that(data[0][0], is.equalTo('npm-install-missing')); + assert.that(data[0][1], is.equalTo('git+https://github.com/AlexCline/npm-install-missing.git')); + missing_mods = data; + done(); + }); + }); + }); + + + describe('#installModule', function(){ + it('should install the test_dependency module', function(done){ + npm_install_missing.installModule(missing_mods[0], function(err, result){ + assert.that(result.length, is.greaterThan(1)); + done(); + }); + }); + }); +}); From 519a39039d3b48dd93b444e6d8dba8b71e64dcc6 Mon Sep 17 00:00:00 2001 From: Raif Harik Date: Sun, 6 Sep 2015 16:29:43 -0500 Subject: [PATCH 2/2] removed .idea folder (generated by webstorm) --- .idea/.name | 1 - .idea/misc.xml | 14 --- .idea/modules.xml | 8 -- .idea/npm-install-missing.iml | 8 -- .idea/vcs.xml | 6 - .idea/workspace.xml | 220 ---------------------------------- 6 files changed, 257 deletions(-) delete mode 100644 .idea/.name delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/npm-install-missing.iml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/workspace.xml diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 6b60547..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -npm-install-missing \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 19f74da..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index f8014aa..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/npm-install-missing.iml b/.idea/npm-install-missing.iml deleted file mode 100644 index c956989..0000000 --- a/.idea/npm-install-missing.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 52d0cba..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,220 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1441573087115 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file