🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

github-repo

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-repo

A very simple Github repo info API wrapper

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

Fetching Github Repo info with Node.js

A very simple node.js module for fetching information about a Github Repo. This was developed as a helper to a project of mine, and should probably be fixed up and made more robust.

Installing

Clone the repo

cd ~/my/node-project/
git clone git://github.com/mikaelbr/node-repo-github.git

You'll now have a folder called node-repo-github/ in your node-project/. You could rename directory and or move it, if you'd like.

How to use

Firstly you need to require the module. Given the structure above this would be

var githubrepo = require('./node-repo-github/githubrepo.js');

Methods

Now you're ready to use it. As per now, this module only has one method; open. This finds a repo based on user and repo name.

githubrepo.open(username, repo, callback)

Parameters

  • username – The username of the repo owner
  • repo – Full repository name
  • callback – Function to be invoked once there's data

Callback

The callback should look like this

function (err, data) {}

Where err is the error notice and data is the Github response.

Example


// Require module. Edit path to match your structure
var githubrepo = require("../githubrepo.js");

// Look for repo and set callback to log data found
githubrepo.open("mikaelbr", "node-repo-github", function (err, data) {
	if (err) throw err;

	// Log results
	console.log(data);
});

FAQs

Package last updated on 09 Mar 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts