Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

download-github-repo

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

download-github-repo - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

test/fixtures/master/bar/README.md

4

History.md
0.1.0 - February 11, 2013
-------------------------
* add option for branch or tag
0.0.1 - January 26, 2013
------------------------
:sparkles:

@@ -15,3 +15,3 @@

/**
* Download GitHub `repo` to `dest`.
* Download GitHub `repo` to `dest` and callback `fn(err)`.
*

@@ -24,4 +24,3 @@ * @param {String} repo

function download(repo, dest, fn){
var url = 'https://codeload.github.com/' + repo + '/legacy.tar.gz/master';
var file = dest + '.tar.gz';
var url = github(normalize(repo));
var dl = wget.download(url, dest + '.tar.gz');

@@ -42,2 +41,42 @@

});
}
/**
* Return a GitHub url for a given `repo` object.
*
* @param {Object} repo
* @return {String}
*/
function github(repo){
return 'https://codeload.github.com/'
+ repo.owner
+ '/'
+ repo.name
+ '/legacy.tar.gz/'
+ repo.branch;
}
/**
* Normalize a repo string.
*
* @param {String} string
* @return {Object}
*/
function normalize(string){
var owner = string.split('/')[0];
var name = string.split('/')[1];
var branch = 'master';
if (~name.indexOf('#')) {
branch = name.split('#')[1];
name = name.split('#')[0];
}
return {
owner: owner,
name: name,
branch: branch
};
}

4

package.json

@@ -14,3 +14,3 @@ {

],
"version": "0.0.1",
"version": "0.1.0",
"license": "MIT",

@@ -26,2 +26,2 @@ "dependencies": {

}
}
}

@@ -14,3 +14,3 @@

Download a `repo` (eg. `"ianstormtaylor/router"`) to a `destination` folder and `callback`.
Download GitHub `repo` (eg. `ianstormtaylor/router`) to a `destination` folder and `callback`. Defaults to the `master` branch, but you can specify a branch or tag as a URL fragment like `ianstormtaylor/router#my-branch`.

@@ -17,0 +17,0 @@ ## License

@@ -12,7 +12,7 @@

it('should work', function(done){
download('ianstormtaylor/matchuppps', 'test/tmp', function(err){
it('downloads the master branch by default', function(done){
download('zeke/download-github-repo-fixture', 'test/tmp', function(err){
if (err) return done(err);
var actual = read('test/tmp');
var expected = read('test/fixture');
var expected = read('test/fixtures/master');
assert.deepEqual(actual, expected);

@@ -22,2 +22,13 @@ done();

});
it('download branches too', function(done){
download('zeke/download-github-repo-fixture#my-branch', 'test/tmp', function(err){
if (err) return done(err);
var actual = read('test/tmp');
var expected = read('test/fixtures/my-branch');
assert.deepEqual(actual, expected);
done();
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc