Socket
Socket
Sign inDemoInstall

githulk

Package Overview
Dependencies
70
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.2 to 0.0.3

91

endpoints/repository.js

@@ -26,5 +26,94 @@ 'use strict';

return this.send(['repos', project.user, project.repo, 'readme'], options, args.fn);
return this.send(
['repos', project.user, project.repo, 'readme'],
options,
args.fn
);
};
/**
* Retrieve the raw contents of a file from the repository.
*
* @param {String} project The project details.
* @param {Object} options Optional options.
* @param {Function} fn The Callback.
* @api private
*/
Repository.prototype.raw = function raw(args) {
args = this.api.args(arguments);
var project = this.api.project(args.str)
, options = args.options || {};
options.headers = options.headers || {};
options.headers.Accept = options.headers.Accept || 'text/plain';
options.branch = options.branch || 'master';
options.api = 'https://raw.github.com/';
return this.send(
[project.user, project.repo, options.branch, options.path],
options,
args.fn
);
};
/**
* Retrieve the contents of a file or directory.
*
* @param {String} project The project details.
* @param {Object} options Optional options.
* @param {Function} fn The Callback.
* @returns {Assign}
* @api public
*/
Repository.prototype.contents = function contents(args) {
args = this.api.args(arguments);
var project = this.api.project(args.str)
, options = args.options || {};
options.path = 'contents/'+ (options.path || '');
return this.send(
['repos', project.user, project.repo, options.path],
options,
args.fn
);
};
/**
* It's possible that a user has moved the repository to a new location.
* Github automatically redirects you when you access the old page. But it
* doesn't provide any redirection for API calls causing them to fail with
* 404's.
*
* In order to detect the correct repository location we need to do a HEAD
* check of the public github URL and use the location header as source URL
* when we're presented with a 301 status code.
*
* @param {String} project The project details.
* @param {Function} fn The Callback.
* @returns {Assign}
* @api public
*/
Repository.prototype.moved = function moved(args) {
args = this.api.args(arguments);
var project = this.api.project(args.str)
, api = this.api;
return this.send([project.user, project.repo], {
api: 'https://github.com/',
method: 'HEAD'
}, function gothead(err, data) {
if (err) return args.fn(err);
var parsed = api.project(data[0].res.request.href)
, changed = parsed.user !== project.user
|| parsed.repo !== project.repo;
args.fn(undefined, parsed, changed);
});
};
//

@@ -31,0 +120,0 @@ // Expose the repository API

@@ -7,2 +7,3 @@ 'use strict';

/**
* GitHulk smash API.
*

@@ -41,2 +42,10 @@ * @constructor

}
//
// No user / password, no predefined authorization, so maybe we've received
// an oauth token.
//
if (!this.authorization && options.token) {
this.authorization = 'token '+ options.token;
}
},

@@ -43,0 +52,0 @@

2

package.json
{
"name": "githulk",
"version": "0.0.2",
"version": "0.0.3",
"description": "Small but powerful Github client",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc